HP Compilers for HP Integrity Servers (September 2011)

Example 3 Code from Example 1 generated using predication
cmp.ne.unc p1,p2 = a,0 ;;
(p2) mov x = 5
(p1) ld x = [p]
In Example 3 (page 7), all branches have been eliminated and the assignments to x
are now data-dependent upon the compare that defines the qualifying predicate.
Control speculation
Control speculation is the execution of an instruction before the execution of all of the
conditions controlling its execution. Using control speculation, the compiler can generate
code which causes the program to execute conditional code concurrently with a guarding
condition, even ahead of a guarding condition, rather than waiting for the result of the
guarding condition evaluation. Such concurrency can significantly improve runtime
performance.
Example 4 Control speculation code
int a,b;
extern int *p;
extern int global;
if(condition) {
a = global;
b = *p + 2;
}
Using control speculation, the HP compiler can cause the program to execute portions
of the two assignment statements in the then clause ahead of the condition.
Loads and arithmetic operations on integer variables are ideal candidates for control
speculation because they do not cause undesired side effects. A source code statement
may utilize loads, arithmetic operations, and stores. If the source code statement is
guarded by a condition evaluation, the loads and arithmetic operations can be speculated;
any store operations are dependent on the condition evaluation and cannot be speculated.
Calls are also exempt from control speculation.
Because the speculative load is being performed ahead of the guarding condition, it is
possible (for a variety of reasons) that the load might not be successful. Unsuccessful
speculative loads result in a speculation token (called a NaT) in the target register. This
NaT token propagates through subsequent instructions. After the guarding condition is
finally evaluated, the results of the speculated instructions are used if they are still needed.
If any NaT token is found, a recovery code sequence is executed which recomputes the
needed results.
Optimizing for Integrity servers 7