Table 27 Optimization levels (continued)
| Optimizations |
|
|
|
Option | performed | Advantages | Disadvantages | Recommended use |
|
|
|
|
|
| branch optimization, | compiles faster than |
|
|
| dead code | level 2; compatible with |
|
|
| elimination, more | the debugger option |
|
|
| efficient use of |
|
| |
| registers, instruction |
|
|
|
| scheduling, and |
|
|
|
| peephole |
|
|
|
| optimization. |
|
|
|
|
|
|
|
|
+O2, | Default level | Can significantly | Compiles slower | During program development |
| optimizations, | increase performance | than level 0 and | and when building the |
| including level 1, | over level 1; works with | 1. | production version; especially |
| plus coloring register | debugger |
| effective in optimizing loops that |
| allocation, induction |
|
| perform arithmetic operations |
| variable elimination |
|
| on large float and double |
| and strength |
|
| arrays. |
| reduction, common |
|
|
|
| subexpression |
|
|
|
| elimination, loop |
|
|
|
| invariant code |
|
|
|
| motion, store/copy |
|
|
|
| optimization, unused |
|
|
|
| definition elimination, |
|
|
|
| software pipelining, |
|
|
|
| and register |
|
|
|
| reassociation. |
|
|
|
|
|
|
|
|
+O3 | Level 2 | Can significantly | Compiles slower | When building the production |
| optimizations, plus | increase performance | than lower levels; | version; especially effective |
| loop transforms, | over level 2. | increases object | when used on source files |
| parallelization, |
| code size; not | containing frequently executed |
| vectorization, |
| compatible with | loops and subprograms. |
| cloning, and inlining |
| the debugger |
|
| within a file. Some |
| option |
|
| optimizations may |
|
|
|
| require additional |
|
|
|
| options; see “Using |
|
|
|
|
|
|
| |
|
|
|
| |
|
|
|
|
|
+O4 | Level 3 optimizations | Provides the highest | Can use large | When building the production |
| applied across all | level of optimization; | amounts of | version; especially effective |
| program files | can significantly | system resources; | when used on source files |
| compiled with +O4. | increase performance | may increase | containing frequently executed |
|
| over level 3. | loops and subprograms. | |
|
|
| object code size; |
|
|
|
| not compatible |
|
|
|
| with the |
|
|
|
| debugger option |
|
|
|
|
|
The +Ooptimizationoptions enable you to control the kind of optimizations that are applied to your program at each level. Table on page151 and
Using options to control optimization | 91 |