Hi!
On Mon, Apr 02, 2001 at 02:19:48PM +0200, you wrote:
> Because -O3 is the same as -O2 -funroll-loops, IIRC, which produces larger
> binaries not gaining any significant speedup.
Not quite:
-- snip --
`-O'
`-O1'
Optimize. Optimizing compilation takes somewhat more time, and a
lot more memory for a large function.
Without `-O', the compiler's goal is to reduce the cost of
compilation and to make debugging produce the expected results.
Statements are independent: if you stop the program with a
breakpoint between statements, you can then assign a new value to
any variable or change the program counter to any other statement
in the function and get exactly the results you would expect from
the source code.
Without `-O', the compiler only allocates variables declared
`register' in registers. The resulting compiled code is a little
worse than produced by PCC without `-O'.
With `-O', the compiler tries to reduce code size and execution
time.
When you specify `-O', the compiler turns on `-fthread-jumps' and
`-fdefer-pop' on all machines. The compiler turns on
`-fdelayed-branch' on machines that have delay slots, and
`-fomit-frame-pointer' on machines that can support debugging even
without a frame pointer. On some machines the compiler also turns
on other flags.
`-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.
`-O2' turns on all optional optimizations except for loop unrolling
and function inlining. It also turns on the `-fforce-mem' option
on all machines and frame pointer elimination on machines where
doing so does not interfere with debugging.
`-O3'
Optimize yet more. `-O3' turns on all optimizations specified by
`-O2' and also turns on the `inline-functions' option.
`-O0'
Do not optimize.
`-Os'
Optimize for size. `-Os' enables all `-O2' optimizations that do
not typically increase code size. It also performs further
optimizations designed to reduce code size.
If you use multiple `-O' options, with or without level numbers,
the last such option is the one that is effective.
-- snip --
Thus, -O3 enables -finline-functions, which - quite similar to
-funroll-loops - produces code that's much larger, but in general not
that much faster. It's IMO much more effective to decide yourself which
functions to inline.
Ciao
Thomas
--
Thomas Binder (Gryf @ IRCNet) gryf@hrzpub.tu-darmstadt.de
PGP-key available on request!
Vote against SPAM: http://www.politik-digital.de/spam/
Attachment:
pgpiGZ_NIlg0K.pgp
Description: PGP signature