7.6.6 Options for Controlling Optimization
The following options control compiler optimizations. Optimization levels available depend on the compiler license (see the Optimizations section).
Option | License | Definition |
---|---|---|
-O0 | All | Do not optimize. (This is the
default.) Without The compiler only allocates variables declared
|
-O
| All | Optimize for both speed and size.
Optimizing compilation takes somewhat longer, and a lot more host memory
for a large function. With -O , the compiler tries to
reduce code size and execution time. The compiler turns on
-fthread-jumps and -fdefer-pop and
turns on -fomit-frame-pointer . |
-O2 | All | Optimize more for speed.
-O2 turns on all optional optimizations except for
loop unrolling (-funroll-loops ), function inlining
(-finline-functions ), and strict aliasing
optimizations (-fstrict-aliasing ). It also turns on
Frame Pointer elimination (-fomit-frame-pointer ). As
compared to -O , this option increases both compilation
time and the performance of the generated code. |
-O3 | PRO | Optimize even more for speed (superset
of -O2 ). -O3 turns on all
optimizations specified by -O2 and also turns on the
inline-functions option. |
-Os | PRO | Optimize even more for size (superset
of -O2 ). -Os enables all
-O2 optimizations that do not typically increase
code size. It also performs further optimizations designed to reduce
code size. |