HP Fortran Programmer Guide (766160-001, March 2014)

Table 27 Optimization levels (continued)
Recommended useDisadvantagesAdvantages
Optimizations
performedOption
compiles faster than
level 2; compatible with
branch optimization,
dead code
the debugger option
-g.
elimination, more
efficient use of
registers, instruction
scheduling, and
peephole
optimization.
During program development
and when building the
Compiles slower
than level 0 and
1.
Can significantly
increase performance
over level 1; works with
debugger option-g.
Default level
optimizations,
including level 1,
plus coloring register
allocation, induction
+O2, -O
production version; especially
effective in optimizing loops that
perform arithmetic operations
variable elimination on large float and double
arrays.and strength
reduction, common
subexpression
elimination, loop
invariant code
motion, store/copy
optimization, unused
definition elimination,
software pipelining,
and register
reassociation.
When building the production
version; especially effective
Compiles slower
than lower levels;
Can significantly
increase performance
over level 2.
Level 2
optimizations, plus
loop transforms,
+O3
when used on source filesincreases object
parallelization, containing frequently executed
loops and subprograms.
code size; not
compatible withvectorization,
the debugger
option -g.
cloning, and inlining
within a file. Some
optimizations may
require additional
options; see “Using
the optimization
options” (page 91).
When building the production
version; especially effective
Can use large
amounts of
Provides the highest
level of optimization;
Level 3 optimizations
applied across all
+O4
when used on source filessystem resources;can significantlyprogram files
compiled with +O4. containing frequently executed
loops and subprograms.
may increase
link-time and
increase performance
over level 3.
object code size;
not compatible
with the
debugger option
-g.
Using the optimization options
The +Ooptimizationoptions enable you to control the kind of optimizations that are applied to
your program at each level. Table on page151 and Table6-3 on page152 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 +Onoption to specify the optimization level
listed in the second column of the tables. The +Oalloption automatically invokes the optimizer at
the highest level.
Using options to control optimization 91