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

Performance and optimization
Using options to control optimization
Chapter 6 149
where opt-level is an integer in the range 0-2. If you use the -g option at a higher level
of optimization, the compiler lowers the level to 2 and compiles for debugging.
Table 6-1 Optimization levels
Option
Optimizations
performed Advantages Disadvantages
Recommended
use
+O0
default
Constant folding and
partial evaluation of test
conditions.
Compiles fastest;
compatible with
the debugger
option -g.
Does very little
optimization.
During program
development.
+O1 Level 0 optimizations,
plus branch optimization,
dead code elimination,
more efficient use of
registers, instruction
scheduling, and peephole
optimization.
Produces faster
programs than
level 0; compiles
faster than level
2; compatible
with the debugger
option -g.
Compiles slower
than level 0.
During program
development.
+O2, -O Default level
optimizations, including
level 1, plus coloring
register allocation,
induction variable
elimination and strength
reduction, common
subexpression elimination,
loop invariant code
motion, store/copy
optimization, unused
definition elimination,
software pipelining, and
register reassociation.
Can significantly
increase
performance over
level 1; works
with debugger
option -g.
Compiles slower
than level 0 and 1.
During program
development and
when building the
production version;
especially effective
in optimizing loops
that perform
arithmetic
operations on large
float and double
arrays.