HP C Programmer's Guide (92434-90009)

66 Chapter4
Optimizing HP C Programs
Specifying Maximum Optimization
cc +O4 +Osize
sourcefile
.c
Most optimizations improve execution speed and decrease executable code size. A few
optimizations significantly increase code size to gain execution speed. The +Osize option
disables these code-expanding optimizations.
Use this option if you have limited main memory, swap space, or disk space.
Specifying Maximum Optimization
To get maximum optimization, use:
cc +Oall
Performs maximum optimization.
Use +Oall with stable, well-structured, ANSI-conforming code. These types of
optimizations give you the fastest code, but are riskier than the default optimizations.
You can use +Oall at optimization levels 2, 3, and 4. The default is +Onoall.
The +Oall option by itself (specified without the +02, +03, or +04 options) combines the
+O4 +Oaggressive +Onolimit options. This combination performs aggressive
optimizations with unrestricted compile time at the highest level of optimization.
Combining Optimization Parameters
Optimization parameters that affect code size, compile-time, and the aggressiveness of the
optimizations performed can be combined with a level of optimization.
For example, to specify conservative optimizations at level 2 and disable code-expanding
optimizations, use:
cc +O2 +Oconservative +Osize
sourcefile
.c
+Olimit and +Osize can be used with either +Oaggressive or +Oconservative.
You cannot use +Oaggressive with +Oconservative.