HP C Programmer's Guide (92434-90009)

64 Chapter4
Optimizing HP C Programs
Changing the Aggressiveness of Optimizations
Changing the Aggressiveness of Optimizations
At each level of optimization, you can control the aggressiveness of the optimizations
performed.
Use the +Oconservative option at optimization level 2, 3, or 4 if you are not sure if your
code conforms to standards. This option provides more safety.
Use the +Oaggressive option at optimization level 2, 3, or 4 for best performance when
you are willing to risk changes to the behavior of your programs. Using the +Oaggressive
option can cause your program to have compilation or run-time problems that require
troubleshooting.
Enabling Only Conservative Optimizations
You can enable conservative optimizations at the second, third, or fourth optimization
levels by using the +Oconservative option, as follows:
cc +O2 +Oconservative
sourcefile
.c
or:
cc +O3 +Oconservative
sourcefile
.c
or:
cc +O4 +Oconservative
sourcefile
.c
Conservative optimizations are optimizations that do not change the behavior of code, in
most cases, even if the code does not conform to standards.
Use the conservative optimizations provided with level 2, 3, and 4 when your code is
non-ANSI.
Enabling Aggressive Optimizations
To enable aggressive optimizations at the second, third, or fourth optimization levels,
use the +Oaggressive option as follows:
cc +O2 +Oaggressive
sourcefile
.c
or:
cc +O3 +Oaggressive
sourcefile
.c
or:
cc +O4 +Oaggressive
sourcefile
.c