C++ User's Guide

Values

On the SPARC Platform:

-xO is equivalent to -xO2.

-xO1 does only the minimum amount of optimization (peephole), which is postpass, assembly-level optimization. Do not use -xO1 unless using -xO2 or -xO3 results in excessive compilation time, or you are running out of swap space.

-xO2 does basic local and global optimization, which includes:

This level does not optimize references or definitions for external or indirect variables. In general, this level results in minimum code size.

-xO3, in addition to optimizations performed at the -xO2 level, also optimizes references and definitions for external variables. This level does not trace the effects of pointer assignments. When compiling either device drivers that are not properly protected by volatile or programs that modify external variables from within signal handlers, use -xO2. In general, -xO3 results in increased code size. If you are running out of swap space, use -xO2.

-xO4 does automatic inlining of functions contained in the same file in addition to performing -xO3 optimizations. This automatic inlining usually improves execution speed but sometimes makes it worse. In general, this level results in increased code size.

-xO5 generates the highest level of optimization. It is suitable only for the small fraction of a program that uses the largest fraction of computer time. This level uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time. Optimization at this level is more likely to improve performance if it is done with profile feedback. See "-xprofile=p".

On the x86 Platform:

-xO1 preloads arguments from memory and causes cross jumping (tail merging), as well as the single pass of the default optimization.

-xO2 schedules both high- and low-level instructions and performs improved spill analysis, loop memory-reference elimination, register lifetime analysis, enhanced register allocation, global common subexpression elimination, as well as the optimization done by level 1.

-xO3 performs loop strength reduction and inlining, as well as the optimization done by level 2.

-xO4 performs architecture-specific optimization, as well as the optimization done by level 3.

-xO5 generates the highest level of optimization. It uses optimization algorithms that take more compilation time or that do not have as high a certainty of improving execution time.