HP Compilers for HP Integrity Servers (September 2011)

Example 8 Typical use of the ESTIMATED_FREQUENCY pragma
if (condition) {
#pragma ESTIMATED_FREQUENCY 0.99
...
for (...) {
#pragma ESTIMATED_FREQUENCY 4.0
...
}
} else {
...
}
In Example 8 (page 15), the code in the then clause of the if statement is expected to
execute 99% of the time (implying that the else clause is executed 1% of the time). The
loop is expected to execute four iterations, on average.
The ESTIMATED_FREQUENCY pragma gives the developer fine-grain control over the
degree of control speculation used by the compiler around any given source code
condition. In addition, knowledge of the average loop iteration count can cause the
compiler to determine that data prefetching would not be effective.
The NO_RETURN pragma asserts to the compiler that the specified function does not
return. This allows the optimizer to simplify the control flow graph, enabling more
aggressive optimization and reduced pressure on the register stack.
Powerful high-level optimization
The HP high-level optimizer contains an interprocedural optimizer, a high-level loop
optimizer, and a scalar optimizer.
The interprocedural optimizer is enabled with the option -ipo at optimization levels two
or higher (e.g. +O2 -ipo). Optimization level four (option +O4) implies -ipo. The loop
optimizer is enabled at optimization levels three or higher (options +O3 and +O4). The
scalar optimizer is enabled along with the other high level optimizations.
The option -ipo can be used to compile some or all of an applicationā€™s source files.
Compiling only some modules with -ipo enables intermodule optimizations between
those files. In this mode, only parts of the application are analyzed during IPO by the
compiler and therefore the compiler has to make conservative assumptions about the rest
of the application. This can result in lost optimization opportunities.
For highest performance, it is beneficial to compile all of an applicationā€™s source files
with -ipo; this is called ā€œwhole program mode.ā€ In this mode, the compiler can perform
precise analysis of an application, potentially resulting in better performance.
The high-level optimizer makes use of PBO information and is more effective when used
in combination with PBO (option +Oprofile=use), for example, PBO data improves
function inlining. PBO data can reveal the most likely callee at an indirect call site,
Understanding key features of the HP compilers 15