Using and Porting GNU CC
These options control various sorts of optimizations:
-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.
-O', the compiler only allocates variables declared
register in registers. The resulting compiled code is a little
worse than produced by PCC without `
-O', the compiler tries to reduce code size and execution
When you specify `
-O', the compiler turns on `
-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'. 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,
function inlining, and, on machines where it interfers with debugging,
frame pointer elimination.
-O3' turns on all optimizations specified by `
-O2' and also turns on the `
If you use multiple `
-O' options, with or without level numbers,
the last such option is the one that is effective.
Options of the form `
-fflag' specify machine-independent
flags. Most flags have both positive and negative forms; the negative
form of `
-ffoo' would be `
-fno-foo'. In the table below,
only one of the forms is listed---the one which is not the default.
You can figure out the other form by either removing `
This option prevents undesirable excess precision on machines such as
the 68000 where the floating registers (of the 68881) keep more
precision than a
double is supposed to have. For most programs,
the excess precision does only good, but a few programs rely on the
precise definition of IEEE floating point. Use `
-O', member functions defined inside class scope are compiled inline by default; i.e., you don't need to add `
inline' in front of the member function name.
-fforce-mem' may. I am interested in hearing about the difference this makes.
On some machines, such as the Vax, this flag has no effect, because
the standard calling sequence automatically handles the frame pointer
and nothing is saved by pretending it doesn't exist. The
whether a target machine supports this flag. See Registers.
inlinekeyword. Normally this option is used to keep the compiler from expanding any functions inline. Note that if you are not optimizing, no functions can be expanded inline.
If all calls to a given function are integrated, and the function is
static, then the function is normally not output as
assembler code in its own right.
static, nevertheless output a separate run-time callable version of the function.
This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by the optimizations performed when this option is not used.
sqrtfunction are non-negative numbers and that no floating-point values are NaNs.
This option should never be turned on by any `
-O' option since
it can result in incorrect output for programs which depend on
an exact implementation of IEEE or ANSI rules/specifications for
The following options control specific optimizations. The `
option turns on all of these optimizations except `
-funroll-all-loops'. On most machines, the `
turns on the `
-fthread-jumps' and `
but specific machines may handle it differently.
You can use the following flags in the rare cases when ``fine-tuning'' of optimizations to be performed is desired.
ifstatement with an
elseclause, CSE will follow the jump when the condition tested is false.
-fcse-follow-jumps', but causes CSE to follow jumps which conditionally skip over blocks. When CSE encounters a simple
ifstatement with no else clause, `
-fcse-skip-blocks' causes CSE to follow the jump around the body of the
-fschedule-insns', but requests an additional pass of instruction scheduling after register allocation has been done. This is especially useful on machines with a relatively small number of registers and where memory load instructions take more than one cycle.
This option is enabled by default on certain machines, usually those which have no call-preserved registers to use instead.
-funroll-loop' implies both `
-fstrength-reduce' and `
-funroll-all-loops' implies `
-fstrength-reduce' as well as `