Optimization-level Options

Each of the command-line options: -O,-O1, -O2 and -O3 turn on several compiler optimizations. -O and -O1 are practically the same and are only mentioned for compatibility with other compilers. The following table summarizes the optimizations that the compiler applies when you invoke -O1, -O2, or -O3 optimizations.

Option Optimization Affected Aspect of Program
-O1, -O2 global register allocation register use
-O1, -O2 instruction scheduling instruction reordering
-O1, -O2 register variable detection register use
-O1, -O2 common subexpression elimination constants and expression evaluation
-O1, -O2 dead-code elimination instruction sequencing
-O1, -O2 variable renaming register use
-O1, -O2 copy propagation register use
-O1, -O2 constant propagation constants and expression evaluation
-O1, -O2 strength reduction-induction variable simplification instruction,
selection-sequencing
-O1, -O2 tail recursion elimination calls, further optimization
-O1, -O2 software pipelining calls, further optimization
-O3 prefetching, scalar replacement,
loop transformations
memory access, instruction parallelism, predication, software pipelining

For IA-32 and Itanium(TM) architectures, the options can behave in a different way. To specify the optimizations for your program, use options for depending on the target architecture as follows.

IA-32 and Itanium(TM) compilers
-O, -O1, -O2 ON by default. Confines optimizations to the procedural level. Turns ON intrinsics inlining. All three optimizations are equal.
-O3 Enables -O2 option with more aggressive optimizations, for example:
  • prefetching

  • scalar replacement

  • loop transformations

Optimizes for maximum speed, but may not improve performance for some programs.