🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6709

Re: Common subexpression optimization

#6709
From: Jim Giles
Date: Mon, 12 Feb 1990 22:22
20 lines
1262 bytes
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
Technical Details
Message-ID: <14237@lambda.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!lanl!lambda!jlg
References: <2844@pkmab.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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