SLAU132Y September 2004 – June 2021
The C/C++ compiler is able to perform various optimizations. High-level optimizations are performed in the optimizer and low-level, target-specific optimizations occur in the code generator. Use higher optimization levels, such as --opt_level=2 and --opt_level=3, to achieve optimal code.
The easiest way to invoke optimization is to use the compiler program, specifying the --opt_level=n option on the compiler command line. You can use -On to alias the --opt_level option. The n denotes the level of optimization (0, 1, 2, 3, and 4), which controls the type and degree of optimization.
Performs all --opt_level=0 (-O0) optimizations, plus:
Performs all --opt_level=1 (-O1) optimizations, plus:
Performs all --opt_level=2 (-O2) optimizations, plus:
If you use --opt_level=3 (-O3), see Section 4.4 and Section 4.5 for more information.
Performs link-time optimization. See Section 4.7 for details.
For details about how the --opt_level and --opt_for_speed options and various pragmas affect inlining, see Section 3.12.
Debugging is enabled by default, and the optimization level is unaffected by the generation of debug information.
Optimizations are performed by the stand-alone optimization pass. The code generator performs several additional optimizations, particularly processor-specific optimizations. It does so regardless of whether you invoke the optimizer. These optimizations are always enabled, though they are more effective when the optimizer is used.