On Sun, Nov 06, 2005 at 01:32:43PM +0100, Giovanni Bajo wrote: > If -O1 means "optimize, but be fast", what does -O2 mean? And what does -O3 > mean? If -O2 means "the current set of optimizer that we put in -O2", that's > unsatisfying for me.
`-O2' Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify `-O2'. As compared to `-O', this option increases both compilation time and the performance of the generated code. Including loop unrolling to -O2 is IMNSHO a bad idea, as loop unrolling increases code size, sometimes a lot. And the distinction between -O2 and -O3 is exactly in the space-for-speed tradeoffs. On many CPUs for many programs, -O3 generates slower code than -O2, because the cache footprint disadvantages override positive effects of the loop unrolling, extra inlining etc. Jakub