i960 Processor Compiler User's Guide
11-10
11
• This program fragment contains an unconditional branch to the label
directly following the branch. After branch optimization, the branch-
to-next-line sequence is eliminated:
Before After
b .L1 .L1:
.L1:
• In the next program fragment, an unconditional branch follows a
conditional branch. The compiler optimizes this branch sequence by
removing the unconditional branch and reversing the test on the
conditional branch.
Before After
cmpi g1, g2 cmpi g1, g2
be .L1 bne L2
b .L2 .L1:
.L1:
Branch Prediction
The i960 Cx and Hx processors provide a branch-prediction bit in
conditional branch instructions. If the prediction is correct, the branch
takes no cycles to execute; otherwise, the branch takes one or more cycles.
For further information on execution speed during branch prediction, refer
to the i960 Cx Microprocessor User's Manual.
If not profiling, the compiler uses these heuristics to set the branch-
prediction bit:
• For backward branches (likely a loop), the compiler predicts that the
branch is taken so that the loop is executed more than once.
• For forward branches (conditional operations such as
if-then
statements), the compiler predicts that the branch is not taken.
During profile-driven compilation, each branch's observed behavior is
used to set the prediction bit.