Techniques used in optimization level 3
At optimization levels 3 and above, the compiler is more aggressive, making
changes to program semantics that will improve performance even if there is
some risk that these changes will produce different results. Here are some
examples:
- In some cases, X*Y*Z will be calculated as X*(Y*Z) instead of (X*Y)*Z.
This could produce a different result due to rounding.
- In some cases, the sign of a negative zero value will be lost. This could
produce a different result if you multiply the value by infinity.
Getting the most out of optimization levels 2 and 3 provides some suggestions for mitigating
this risk.
At optimization level 3, all of the techniques in optimization level 2
are used, plus the following:
- Unrolling deeper loops and improving loop scheduling.
- Increasing the scope of optimization.
- Performing optimizations with marginal or niche effectiveness, which might
not help all programs.
- Performing optimizations that are expensive in compile time or space.
- Reordering some floating-point computations, which might produce precision
differences or affect the generation of floating-point-related exceptions
(equivalent to compiling with the -qnostrict option).
- Eliminating implicit memory usage limits (equivalent to compiling with
the -qmaxmem=-1 option).
- Performing a subset of high-order transformations (equivalent
to compiling with the -qhot=level=0 option).
- Increasing automatic inlining.
- Propagating constants and values through structure copies.
- Removing the "address taken" attribute if possible after
other optimizations.
- Grouping loads, stores and other operations on contiguous
aggregate members, in some cases using VMX vector register operations.