HP Fortran Programmer's Guide (B3908-90031; September 2011)

Performance and optimization
Using options to control optimization
Chapter 6150
Using the optimization options
The +Ooptimization options enable you to control the kind of optimizations that are applied to your
program at each level. Table on page 151 and Table 6-3 on page 152 list the options. The first column of
each table lists each option, the second column gives the optimization level at which the option can be used,
and the third column identifies what the option does. When using any of these options except +Oall, you
must also use the +On option to specify the optimization level listed in the second column of the tables. The
+Oall option automatically invokes the optimizer at the highest level.
Table 6-2 lists the “packaged” options. These options enable or disable a set of related optimizations, such as
optimizations that do not increase code size. Table 6-3 lists options that enable or disable specific
optimizations.
The options in both tables can be combined on the same command line, except as noted. For example, the
following command line requests aggressive optimizations at level 2 that do not increase code size:
$ f90 +02 +Oaggressive +Osize prog.f90
+O3 Level 2 optimizations,
plus loop transforms,
parallelization,
vectorization, cloning, and
inlining within a file.
Some optimizations may
require additional options;
see “Using the
optimization options” on
page 150.
Can significantly
increase
performance over
level 2.
Compiles slower
than lower levels;
increases object
code size; not
compatible with
the debugger
option -g.
When building the
production version;
especially effective
when used on
source files
containing
frequently executed
loops and
subprograms.
+O4 Level 3 optimizations
applied across all program
files compiled with +O4.
Provides the
highest level of
optimization; can
significantly
increase
performance over
level 3.
Can use large
amounts of system
resources; may
increase link-time
and object code
size; not
compatible with
the debugger
option -g.
When building the
production version;
especially effective
when used on
source files
containing
frequently executed
loops and
subprograms.
Table 6-1 Optimization levels (Continued)
Option
Optimizations
performed Advantages Disadvantages
Recommended
use