gcc Compiler Optimization Options
[From the man gcc page.]
- -O 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', only variables declared register are
allocated in registers.
With `-O', the compiler tries to reduce code size and
Force memory operands to be copied into registers
before doing arithmetic on them. This may produce better
code by making all memory references potential common
subexpressions. When they are not common
subexpressions, instruction combination should eliminate the
Force memory address constants to be copied into
registers before doing arithmetic on them. This may produce
better code just as `-fforce-mem' may.
Pay attention the inline keyword. Normally the
negation of this option `-fno-inline' is used to keep the
compiler from expanding any functions inline.
Integrate all simple functions into their callers. The
compiler heuristically decides which functions are
simple enough to be worth integrating in this way.
Enable values to be allocated in registers that will be
clobbered by function calls, by emitting extra
instructions to save and restore the registers around such
calls. Such allocation is done only when it seems to
result in better code than would otherwise be produced.