Optimization Levels Overview

Each of the command-line options: -O,-O1, -O2 and -O3 turn on several compiler capabilities. -O and -O1 are practically the same and mentioned both for compatibility with other compilers. See the summary of these options.

The following table summarizes the optimizations that the compiler applies when you invoke -O1 and/or -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; for Itanium-based applications,
-O1 turns off software pipelining to reduce the code size

-O3

prefetching, scalar replacement,
loop transformations

memory access, instruction parallelism, predication, software pipelining