Prefetch Unit
ARM DDI 0363G
Copyright © 2006-2011 ARM Limited. All rights reserved.
5-4
ID073015
Non-Confidential
For loops beyond a certain number of iterations, the branch history is not large enough to learn
the history and predict the loop exit. The PFU includes logic to count the number of iterations
(up to 31) of a loop, and thereby predict the not-taken branch that exits the loop. If the number
of iterations taken exceeds 31, the loop branch is never predicted as not-taken.
If multiple branch histories index into the same hint value, this can cause thrashing in the history
table and reduce accuracy of the branch predictor. Logic in the branch predictor detects these
cases and provides some hysteresis for the hint value.
For direct branches, the target address is calculated statically from the instruction encoding and
the program counter. For indirect branches, the hint value predicts if the branch is taken or
not-taken, and the return stack can sometimes be used to predict the target address. When the
destination of a branch cannot be calculated statically, or popped from the return stack, PFU
assumes the branch to be not-taken.
The PFU updates the history for each occurrence of a branch when the DPU indicates how the
branch was resolved.
5.2.2
Incorrect predictions and correction
The DPU resolves branches that the dynamic branch predictor predicts at the Wr-stage of the
pipeline. A misprediction causes the PFU to flush the pipeline and fetch the correct instruction
stream.