Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: Aggressive optimization Message-ID: <14780:Nov1605:10:4490@kramden.acf.nyu.edu> Date: 16 Nov 90 05:10:44 GMT References: <9576:Nov1523:11:0990@kramden.acf.nyu.edu> <6096@lanl.gov> Organization: IR Lines: 43 In article <6096@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > From article <9576:Nov1523:11:0990@kramden.acf.nyu.edu>, by brnstnd@kramden.acf.nyu.edu (Dan Bernstein): > > [...] Matt pointed out that gcc did much > > better. gcc, however, will produce suboptimal code for > > for (j = 0;j < 100;j++) > > a[i * j] = ...; > Huh? This is a _trivial_ example of induction variable elimination. I agree entirely. But gcc can't do it. (Sun's optimizer sort of does, though as usual it fails to compress the j computation.) All you wanted was real examples for real optimizers. I had thought that you were listening when other people posted real examples. Apparently not. Now I've posted the examples for you. > I suspect that the compiler couldn't optimize it because it couldn't > tell whether 'i' was aliased to part of 'a' or not. No, there was no danger of this. Sun's optimizer can tell. gcc's can too, when the ``i *'' is removed. > In C, I hand optimize by converting it into another language which > runs faster. I think your definition of ``hand optimize'' is a bit screwy here, though I sympathize with what you're saying. The way people optimize Ada is to write it in a different language first, then run it through a preprocessor. > By the way, this is my _last_ response to Dan Bernstein. It is not > worth the aggravation to try to discuss anything with someone whose > only discussion technique is invective. You always do this. Whenever you lose an argument you first blithely assume that you were right all along, then try to squirm out of your mistakes, then give up communication. > If I don't mention him directly, > maybe he won't feel personally threatened. Stop projecting your paranoia onto other people. ---Dan