Path: utzoo!utgpu!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: <13405:Oct1800:22:5690@kramden.acf.nyu.edu> Date: 18 Oct 90 00:22:56 GMT References: <65697@lanl.gov> <1458@exodus.Eng.Sun.COM> Organization: IR Lines: 35 In article <1458@exodus.Eng.Sun.COM> chased@rbbb.Eng.Sun.COM (David Chase) writes: > (AND, the optimizer will optimize for > different machines, unlike the manual optimizer). quickpick would remedy that, permanently. > How often do you > catch an optimizer bug, and often do you make a mistake > hand-optimizing code? First releases of optimizers simply don't work; after they've spent a few years on the market, their bugs are few and far between. Maybe one bug per ten thousand lines of code, after a year of maturity. It goes down quickly past that. I do not remember ever making a mistake in hand optimization by the most fundamental standard technique: adding variable x to keep track of some intermediate quantity, and eliminating redundant variables given x. What optimizer can do this for any but the most primitive intermediate expressions? (Introducing a pointer to traverse an array, and eliminating the index that it replaces, is the simplest example.) It would be interesting to see a language where you could say ``Okay, keep 4*k + j - foo(i) in a register, and use it wherever possible.'' Somehow I don't think we have the technology yet. [ example of code: 30x faster from better algorithms, etc., in ] [ several weeks, 1.7x faster from optimizer in a couple of minutes ] But I can usually get another 2x to 5x out of lots of ``picky'' hand optimizations, having nothing to do with the algorithms. And I'm not going to introduce subtle bugs in weird cases with unsafe program transformations. ---Dan