HPlogo HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 4 Optimizing HP C Programs

Summary of Major Optimization Levels

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The HP C major optimization options are summarized in Table 4-1 “HP C Major Optimization Options ”.

Table 4-1 HP C Major Optimization Options

Option

Description

Benefits

+O0 (default)

Constant folding and simple register assignment.

Compiles fastest.

+O1

Level 0 optimizations plus instruction scheduling and optimizations that can be performed on small sections of code.

Produces faster programs than level 0. Compiles faster than level 2.

+O2 or -O

Level 1 optimizations, plus optimizations performed over entire functions in a single file. Optimizes loops in order to reduce pipeline stalls. Performs scalar replacement, and analysis of data-flow, memory usage, loops and expressions.

Can produce faster run-time code than level 1 if programs use loops extensively. Compiles faster than level 3. Loop-oriented floating point intensive applications may see run times reduced by 50%. Operating system and interactive applications that use the already optimized system libraries can achieve 30% to 50% additional improvement.

+O3

Level 2 optimizations, plus full optimization across all subprograms within a single file. Includes subprogram inlining.

Can produce faster run-time code than level 2 on code that frequently calls small functions. Links faster than level 4.

+O4

Level 3 optimizations, plus full optimizations across the entire application program. Includes global and static variable optimization and inlining across the entire program. Optimizations are performed at link-time.

Produces faster run-time code than level 3 if programs use many global variables or if there are many opportunities for inlining procedure calls.

 

© Hewlett-Packard Development Company, L.P.