An example uses a basic block with four possible successors. The following Itanium
architecture-based multi-target branch code uses a BBB bundle template and can
branch to either block B, block C, block D, or fall through to block A:
label_AA:
{ .bbb
(p1)
(p2)
(p3)
}
label_A:
The ordering of branches is important for program correctness unless all branches are
mutually exclusive, in which case the compiler can choose any ordering desired.
4.3.3
Selecting Multiple Values for One Variable or Register with
Predication
A common occurrence in programs is for a set of paths that compute different values
for the same variable to join and then continue. A variant of this is when separate paths
need to compute separate results but could otherwise use the same registers since the
paths are known to be complementary. The use of predication can optimize these
cases.
4.3.3.1
Selecting One of Several Values
When several control paths that each compute a different value of a single variable
meet, a sequence of conditionals is usually required to select which value will be used
to update the variable. The use of predication can efficiently implement this code
without branches:
The entire switch-block above can be executed in a single cycle using predication if all
of the predicates have been computed earlier. Assume that if rW equals 1, 2, or 3, then
one of p1, p2, or p3 is true, respectively:
(p1)
(p2)
(p3)
Without this predication capability, numerous branches or conditional move operations
would be needed to collapse these values.
1:174
... // Instructions in block AA
br.cond label_B
br.cond label_C
br.cond label_D
// Fall through to A
... // Instructions in block A
switch (rW)
case 1:
rA = rB + rC;
break;
case 2:
rA = rE + rF;
break;
case 3:
rA = rH - rI;
break;
add
rA=rB,rC
add
rA=rE,rF
sub
rA=rH,rI;;
Volume 1, Part 2: Predication, Control Flow, and Instruction Stream
Need help?
Do you have a question about the ITANIUM ARCHITECTURE - SOFTWARE DEVELOPERS MANUAL VOLUME 1 REV 2.3 and is the answer not in the manual?
Questions and answers