Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!haven!adm!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: Aggressive optimization Message-ID: <6096@lanl.gov> Date: 16 Nov 90 00:24:00 GMT References: <9576:Nov1523:11:0990@kramden.acf.nyu.edu> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 38 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 suspect that the compiler couldn't optimize it because it couldn't tell whether 'i' was aliased to part of 'a' or not. This only happens in languages in which pointers and arrays are confused. It doesn't happen in languages which _really_ have arrays (as opposed to a shorthand that's preprocessed into pointers). > [...] >> I hand optimize in ASSEMBLY all the time. > > Good to see you're awake. However, I think you'd find some rather > impressive gains from hand optimization in any language, if you just > took the time to practice. I do hand optimize in other languages. the technique is just different in each. In high-level languages (where I don't have direct control over instruction selection or register allocation), I don't _try_ to hand optimize in ways which requires such control to be successful. In C, I hand optimize by converting it into another language which runs faster. J. Giles 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. If (an very implausible if) Dan ever writes something with useful technical merit I will discuss it in a general way without naming names. I suspect that the only reason he doesn't discuss things more rationally is that he's afraid to admit he's wrong. If I don't mention him directly, maybe he won't feel personally threatened.