EasyManua.ls Logo

AMCC PPC405 - Branch Prediction; Table 2-9. Conditional Branch BO Field

Default Icon
450 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
AMCC Proprietary 52
Revision 1.02 - September 10, 2007
PPC405 Processor
Preliminary User’s Manual
Table 2-9 lists specific BO field contents, and the resulting actions; z represents a mandatory value of 0, and y is a
branch prediction option discussed in Branch Prediction on page 52.
2.7.5 Branch Prediction
Conditional branches present a problem to the instruction fetcher. A branch might be taken. The branch EXU
attempts to predict whether or not a branch is taken before all information necessary to determine the branch
direction is available. This decision is called a branch prediction. The fetcher can then prefetch instructions starting
at the predicted branch target address. If the prediction is correct, time is saved because the branched-to
instruction is available in the instruction queue. Otherwise, the instruction pipeline stalls while the correct
instruction is fetched into the instruction queue. To be effective, branch prediction must be correct most of the time.
The PowerPC Architecture enables software to reverse the default branch prediction, which is defined as follows:
Predict that the branch is to be taken if ((BO[0] BO[2])
s)= 1
where
s is the sign bit of the displacement for conditional branch (bc) instructions, and 0 for bclr and bcctr
instructions.
(BO[0] BO[2]) = 1 only when the conditional branch tests nothing (the “branch always” condition). Obviously, the
branch should be predicted taken for this case.
If the branch tests anything, (BO[0] BO[2]) = 0, and
s entirely controls the prediction. The default prediction for
this case was decided by considering the relative form of bc, which is commonly used at the end of loops to control
the number of times that a loop is executed. The branch is taken every time the loop is executed except the last, so
it is best if the branch is predicted taken. The branch target is the beginning of the loop, so the branch
displacement is negative and
s =1.
If branch displacements are positive (
s = 0), the branch is predicted not taken. If the branch instruction is any form
of
bclr or bcctr except the “branch always” forms, then s = 0, and the branch is predicted not taken.
There is a peculiar consequence of this prediction algorithm for the absolute forms of bc (bca and bcla). As
described in Unconditional Branch Target Addressing Options on page 50, if the algebraic sign of the displacement
is negative (
s = 1), the branch target address is in high memory. If the algebraic sign of the displacement is positive
(s = 0), the branch target address is in low memory. Because these are absolute-addressing forms, there is no
reason to treat high and low memory differently. Nevertheless, for the high memory case the default prediction is
taken, and for the low memory case the default prediction is not taken.
Table 2-9. Conditional Branch BO Field
BO Value Description
0000
y Decrement the CTR, then branch if the decremented CTR 0 and CR[BI]=0.
0001
y Decrement the CTR, then branch if the decremented CTR = 0 and CR[BI] = 0.
001
zy Branch if CR[BI] = 0.
0100
y Decrement the CTR, then branch if the decremented CTR 0 and CR[BI] = 1.
0101
y Decrement the CTR, then branch if the decremented CTR=0 and CR[BI] = 1.
011
zy Branch if CR[BI] = 1.
1
z00y Decrement the CTR, then branch if the decremented CTR 0.
1
z01y Decrement the CTR, then branch if the decremented CTR = 0.
1
z1zz Branch always.

Table of Contents