Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!pilchuck!dataio!fnx!nazgul!bright From: bright@nazgul.UUCP (Walter Bright) Newsgroups: comp.lang.c Subject: Re: Heroic constant folding (was micro-optimizing loops etc.) Message-ID: <287@nazgul.UUCP> Date: 23 Mar 91 11:28:48 GMT References: <10191@dog.ee.lbl.gov> <14522@ganymede.inmos.co.uk> <10450@dog.ee.lbl.gov> <1991Mar2.010049.21044@grebyn.com> Reply-To: bright@nazgul.UUCP (Walter Bright) Organization: Zortech, Seattle Lines: 16 In article rjohnson@shell.com (Roy Johnson) writes: />Of course, the best optimization for: /> for (i = 1; i < 100; i++) /> x += i; />is: /> x += 4950; /This doesn't look to be such a bad thing to optimize away (speaking /with all the authority of one who doesn't write compilers). Actually, it is probably not worth the bother to attempt to optimize away. In general, a program that needs to be optimized is one that is going to be run many times. A loop that is determinate (doesn't change from run to run) generally does not appear in a program that is to be run many times. There are still lots of unexploited opportunities for optimizations in code that *does* commonly appear in production programs.