Option Type | Default Value | #pragma options | C | C++ |
-qoption -flag |
nooptimize | - | x | all except: -O4 -qoptimize=4 OPTimize=4 |
Syntax
-O | -O2 | -O3 | -O4 | -qoptimize | -qoptimize=2 | -qoptimize=3 | -qoptimize=4 | -qnooptimize | -qoptimize=0 OPTimize | OPTimize=2 | OPTimize=3 | OPTimize=4 | NOOPTimize | OPTimize=0
Purpose
Optimizes code at a choice of levels during compilation.
Notes
You can abbreviate -qoptimize... to -qopt.... For
example, -qnoopt is equivalent to -qnooptimize.
Increasing the level of optimization may or may not result in additional performance improvements, depending on whether additional analysis detects further opportunities for optimization.
Compilations with optimizations may require more time and machine resources than other compilations.
Optimization can cause statements to be moved or deleted, and generally should not be specified along with the -g flag for the dbx symbolic debug program. The debugging information produced may not be accurate.
The levels of optimization are:
-qNOOPTimize | (Same as -qOPTimize=0.) Performs only quick local
optimizations such as constant folding and elimination of local common subexpressions. This setting implies -qstrict_induction unless -qnostrict_induction is explicitly specified. |
-O, -qOPTimize | Performs optimizations that the compiler developers considered the best
combination for compilation speed and runtime performance. The optimizations may change from product release to the next. If you need a specific level of optimization, specify the appropriate numeric value. This setting implies -qnostrict_induction unless -qstrict_induction is explicitly specified. |
-O2, -qOPTimize=2 | Same as -O. |
-O3, -qOPTimize=3 | Performs additional optimizations that are memory intensive, compile-time
intensive, or both. These optimizations are performed in addition to those performed with
only the -O option specified. They are recommended when the desire for
runtime improvement outweighs the concern for minimizing compilation resources. This level is the compiler's highest and most aggressive level of optimization. -O3 performs optimizations that have the potential to slightly alter the semantics of your program. It also applies the -O2 level of optimization with unbounded time and memory. The compiler guards against these optimizations at -O2. You can use the -qstrict option with -O3 to turn off the aggressive optimizations that might change the semantics of a program. -qstrict combined with -O3 invokes all the optimizations performed at -O2 as well as further loop optimizations. Note that the -qstrict compiler option must appear after the -O3 option, otherwise it is ignored. The aggressive optimizations performed when you specify -O3 are:
Notes
|
-O4, -qOPTimize=4 | Valid only for C program compilations. This option is the same as -O3, except that it also:
Note: Later settings of -O, -qipa, -qarch, and -qtune options will override the settings implied by the -O4 option. |
Example
To compile myprogram.c for maximum optimization, enter:
xlC myprogram.c -O3
For an in-depth discussion of how to optimize and tune your programs, refer to the Optimization and Tuning Guide for Fortran, C, and C++.
Program Optimization with IBM C and C++ Compilers
Writing Optimized Program Source Code
Mimimizing the Size of Object Files
List of Compiler Options and Their Defaults
Options that Define the Compiler Object Code Produced