From: "Andrew Crabtree" Newsgroups: comp.os.msdos.djgpp Subject: Re: Why only -O2? Date: Mon, 26 Jan 1998 16:12:11 -0800 Organization: Hewlett Packard Lines: 42 Message-ID: <6aj8o1$cur$1@rosenews.rose.hp.com> References: <6aijk6$4g6 AT news DOT xgw DOT fi> NNTP-Posting-Host: ros51675cra.rose.hp.com Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Sampo Niskanen wrote in message <6aijk6$4g6 AT news DOT xgw DOT fi>... >Why do so many programs which come in sources on default use the option >-O2 in their makefiles? There are several reasons why a lower optimization number may be preferable. 1) Often times the optimizations enabled at a higher level produce slower code. Most of the default optimization virtually always (95% maybe) generate faster code. The obscure ones might only benefit you 60% of the time, do nothing 20% of the time and slow you down the remaiming 20%. 2) Optimization takes a long time. For a huge project enabling all optimizations may add hours to the compile time. 3) In some systems (pgcc, possibly others), the higher optimizations values enable less reliable optimizations (the code may be broken). > Shouldn't -O3 optimize even more? Not always. It tries to but whether or not it works depends on the code. >Also, what optimization level does -O use? I think recent versions of gcc (>2.7.2.1) will print out the indicidual options enabled in the assembly output. Probably just the cse, jump, and peephole would be a guess. > Are lower optimization levels >better for debugging, Definitely. It is really annoying to jump all over in code, and to have local variables "disappear" > if so, what would be best? Just not specifying a -O should be sufficient. Andy