HP C Programmer's Guide (92434-90009)

Chapter 4 59
Optimizing HP C Programs
4 Optimizing HP C Programs
This chapter discusses the following:
When and how to use the optimizer.
The four levels of optimization.
Profile-based optimization.
The HP C optimizer transforms programs so machine resources are used more efficiently.
The optimizer can dramatically improve application run-time speed. HP C performs only
minimal optimizations unless you specify otherwise. You activate additional optimizations
using HP C command line options.
There are four major levels of optimization: levels 1, 2, 3, and 4. Level 4 optimization can
produce the fastest executable code. Level 4 is a superset of the other levels.
Additional parameters enable you to control the size of the executable program, compile
time, and aggressiveness of the optimizations performed.
Compile time memory and CPU usage increase with each higher level of optimization due
to the increasingly complex analysis that must be performed. You can control the trade-offs
between compile-time penalties and code performance by choosing the level of optimization
you desire.
Generally, the optimizer is not used during code development. It is used when compiling
production-level code for benchmarking and general use.