IBM Books

User's Guide


Choosing an Optimization Level

Optimization requires additional compilation time, but usually results in a faster run time. XL Fortran allows you to select whether you want optimization to be performed at compile time. By default, the compiler performs only very minor optimizations. For the fastest compile time, we recommend not optimizing a program that you are debugging or compiling to check syntax.

After choosing an optimization level, you can investigate some of the other optimization options mentioned in the following sections. An easy way to choose options that reflect your goals is to run the command xxlf. This features a point-and-click interface to different categories of compiler options.

Figure 23. Optimization Window of the xxlf Application

REQTEXT

Specify the -O compiler option, with an optional digit that signifies the level, to enable compiler optimization. The default level is 2.

-O2 performs control and data flow analysis for the entire program unit. This analysis allows optimizations, such as common expression elimination, strength reduction, code motion, and global register assignment. When you use this option, the compiler pays particular attention to innermost loops and to subscript address calculations. The compiler keeps variables in registers wherever possible to eliminate unnecessary loads and stores.

-O2 performs the following optimization techniques:

-O3 performs the -O2-level optimizations and additional optimizations that may have the following effects:

We recommend that you use the -O3 option where run-time performance is a crucial factor and machine resources can accommodate the extra compile-time work.

The exact optimizations that are performed depend on a number of factors:

Although it is not strictly another optimization level, the -qipa option extends the optimizations across procedures (even if the procedures are in different files). It enhances the effectiveness of the optimizations that are done by other optimization options, particularly -O (at any level) and -Q. Because it can also increase compile time substantially, you may want to use it primarily for tuning applications that are already debugged and ready to be used. Note that the -O4 compiler option implies the -O3 compiler option.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ] © Copyright IBM Corporation 1990, 1998.