Article View: comp.lang.misc
Article #1926Re: C's sins of commission
From: Dan Bernstein
Date: Tue, 06 Nov 1990 07:32
Date: Tue, 06 Nov 1990 07:32
25 lines
1147 bytes
1147 bytes
In article <1990Nov2.052815.22188@murdoch.acc.Virginia.EDU> gl8f@astsun9.astro.Virginia.EDU (Greg Lindahl) writes:
[ on one type of aliasing problem ]
> a[i] = b[i] / c[i];
> d[i] = b[i] * c[i];
[ Fortran sees separate arrays and loads b[i] and c[i] only once ]
[ C sees possible aliasing and loads them twice ]
Hmmm. I would almost automatically optimize the above into
{
register double bi = b[i];
register double ci = c[i];
a[i] = bi / ci;
d[i] = bi * ci;
}
Don't ask me to philosophize about this fragment.
> but
> don't make my code run 30% slower.
Hey, dude, write it 30% faster in the first place.
---Dan
Technical Details
Message-ID:
<2440:Nov607:32:5890@kramden.acf.nyu.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!fernwood!apple!sun-barr!cs.utexas.edu!wuarchive!psuvax1!rutgers!cmcl2!kramden.acf.nyu.edu!brnstndReferences:
<PCG.90Oct30201101@teachk.cs.aber.ac.uk> <3673@stl.stc.co.uk> <1990Nov2.052815.22188@murdoch.acc.Virginia.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!fernwood!apple!sun-barr!cs.utexas.edu!wuarchive!psuvax1!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: C's sins of commission Message-ID: <2440:Nov607:32:5890@kramden.acf.nyu.edu> Date: 6 Nov 90 07:32:58 GMT References: <PCG.90Oct30201101@teachk.cs.aber.ac.uk> <3673@stl.stc.co.uk> <1990Nov2.052815.22188@murdoch.acc.Virginia.EDU> Organization: IR Lines: 25