HPlogo HP C/HP-UX Programmer's Guide: HP 9000 Computers

Chapter 4 Optimizing HP C Programs

» 

Technical documentation

Complete book in PDF

 » Table of Contents

Table of Contents

Summary of Major Optimization Levels
Supporting Optimization Options
Enabling Basic Optimization
Enabling Different Levels of Optimization
Level 1 Optimization
Level 2 Optimization
Level 3 Optimization
Level 4 Optimization
Changing the Aggressiveness of Optimizations
Enabling Only Conservative Optimizations
Enabling Aggressive Optimizations
Removing Compilation Time Limits When Optimizing
Limiting the Size of Optimized Code
Specifying Maximum Optimization
Combining Optimization Parameters
Summary of Optimization Parameters
Profile-Based Optimization
Instrumenting the Code
Collecting Data for Profiling
Performing Profile-Based Optimization
Maintaining Profile Data Files
Maintaining Instrumented and Optimized Program Files
Profile-Based Optimization Notes
Controlling Specific Optimizer Features
+Olevel=name1[,name2,...nameN]
+O[no]autopar
+O[no]dataprefetch
+O[no]dynsel
+O[no]entrysched
+O[no]extern[=name1,name2,...nameN]
+O[no]fail_safe
+O[no]fastaccess
+O[no]fltacc
+O[no]global_ptrs_unique[=name1,name2
,...name]
+O[no]initcheck
+O[no]inline[=name1, name2,...nameN]
+Oinline_budget=n
+O[no]libcalls
+O[no]loop_block
+O[no]loop_transform
+O[no]loop_unroll[=unroll factor]
+O[no]loop_unroll_jam
+O[no]moveflops
+O[no]multiprocessor
+O[no]parallel
+O[no]parmsoverlap
+O[no]pipeline
+O[no]procelim
+O[no]promote_indirect_calls
+O[no]ptrs_ansi
+O[no]ptrs_strongly_typed
+O[no]ptrs_to_globals[=name1, name2, ...nameN]
+O[no]regionsched
+Oreusedir=directory
+O[no]regreassoc
+O[no]report=[report_type]
+O[no]sharedgra
+O[no]sideeffects[=name1, name2, ...nameN]
+O[no]signedpointers
+O[no]static_prediction
+O[no]vectorize
+O[no]volatile
+O[no]whole_program_mode
Using Advanced Optimization Options
Level 1 Optimization Modules
Branch Optimization
Dead Code Elimination
Faster Register Allocation
Instruction Scheduler
Peephole Optimizations
Level 2 Optimization Modules
Coloring Register Allocation
Induction Variables and Strength Reduction
Local and Global Common Subexpression Elimination
Constant Folding and Propagation
Loop Invariant Code Motion
Store/Copy Optimization
Unused Definition Elimination
Software Pipelining
Register Reassociation
Level 3 Optimizations
Inlining within a Single Source File
Example of Inlining
Level 4 Optimizations
Inlining Across Multiple Files
Global and Static Variable Optimization
Guidelines for Using the Optimizer
Optimizer Assumptions
Optimizer Pragmas
Optimizer Control Pragmas
Inlining Pragmas
Alias Pragmas
Aliasing Options
Improving Shared Library Performance
HP_NO_RELOCATION Pragma
HP_LONG_RETURN Pragma
HP_DEFINED_EXTERNAL Pragma
Improving Compile and Link Times

This chapter discusses the following:

  • When and how to use the optimizer.

  • The four levels of optimization.

  • Profile-based optimization.

  • Advanced optimization options and pragmas

  • Improving compile and link time

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 and pragmas.

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.

© Hewlett-Packard Development Company, L.P.