SLAU132V October 2004 – February 2020
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 3.3 and Section 3.4 for more information.
Performs link-time optimization. See Section 3.6 for details.
For information about how the --opt_level option along with the --opt_for_speed option and various pragmas affect inlining, see Section 2.11.
By default, debugging is enabled and the default optimization level is unaffected by the generation of debug information.
The levels of 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, although they are more effective when the optimizer is used.