Mail Archives: djgpp/1998/01/26/20:01:32
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
- Raw text -