These options control various sorts of optimizations:
-O
-O1
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
`-O2' turns on all optional optimizations except for loop unrolling and function inlining. It also turns on frame pointer elimination on machines where doing so does not interfere with debugging.
-O3
-O0
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 `no-' or adding it.
-ffloat-store
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 `-ffloat-store' for such programs.
-fno-default-inline
-fno-defer-pop
-fforce-mem
-fforce-addr
-fomit-frame-pointer
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 machine-description macro FRAME_POINTER_REQUIRED
controls whether a target machine supports this flag. See Registers.
-fno-inline
inline
keyword. 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.
-finline-functions
If all calls to a given function are integrated, and the function is declared static
, then the function is normally not output as assembler code in its own right.
-fkeep-inline-functions
static
, nevertheless output a separate run-time callable version of the function.
-fno-function-cse
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.
-ffast-math
sqrt
function 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 math functions.
The following options control specific optimizations. The `-O2' option turns on all of these optimizations except `-funroll-loops' and `-funroll-all-loops'. On most machines, the `-O' option turns on the `-fthread-jumps' and `-fdelayed-branch' options, 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.
-fstrength-reduce
-fthread-jumps
-fcse-follow-jumps
if
statement with an else
clause, CSE will follow the jump when the condition tested is false.
-fcse-skip-blocks
if
statement with no else clause, `-fcse-skip-blocks' causes CSE to follow the jump around the body of the if
.
-frerun-cse-after-loop
-fexpensive-optimizations
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-fcaller-saves
This option is enabled by default on certain machines, usually those which have no call-preserved registers to use instead.
-funroll-loops
-funroll-all-loops
-fno-peephole