Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!lanl!lambda!jlg From: jlg@lambda.UUCP (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: Common subexpression optimization Message-ID: <14237@lambda.UUCP> Date: 12 Feb 90 22:22:18 GMT References: <2844@pkmab.se> Lines: 20 From article <2844@pkmab.se>, by ske@pkmab.se (Kristoffer Eriksson): > [...] > int a[200][2]; /* Array of 200 arrays of two int. */ > int (*p)[2]; /* Pointer to array of two int. */ > p = a; /* Start with the first array of two int of a. */ > for (i = 0; i < 200; i++) { > (*p)[0] = expr1(i); > (*p)[1] = expr2(i); > p++; /* Note automatic scaling. */ > } Still more obscure than using 'a' directly. Furthermore, using the array notation directly removes the need for _ANY_ pointer increment in the loop (whether it is automatically scaled or not). Other than that, the code is now nearly identical to the code I gave as best - the array indexing is still done _automatically_ by the compiler. Since the supposed advantage of using pointers was _not_ to rely on the compiler for optimizing the index calculations, this version doesn't support Peter Grandi's claims. J. Giles