Program Flow Prediction
ARM DDI 0301H
Copyright © 2004-2009 ARM Limited. All rights reserved.
5-6
ID012310
Non-Confidential, Unrestricted Access
Branch folding is done for all dynamically predicted branches, except that branch folding is not
done for:
•
BL and BLX instructions, to avoid losing the link
•
predicted branches onto branches
•
branches that are breakpointed or have generated an abort when fetched.
5.2.5
Incorrect predictions and correction
Branches are resolved at or before the Ex3 stage of the integer core pipeline. A misprediction
causes the pipeline to be flushed, and the correct instruction stream to be fetched. If branch
folding is implemented, the failure of the condition codes of a folded branch causes the
instruction that follows the folded branch to fail. Whenever a potentially incorrect prediction is
made, the following information, necessary for recovering from the error, is stored:
•
a fall-through address in the case of a predicted taken branch instruction
•
the branch target address in the case of a predicted not taken branch instruction.
The PU passes the conditional part of any optimized branch into the integer core. This enables
the integer core to compare these bits with the processor flags and determine if the prediction
was correct or not. If the prediction was incorrect, the integer core flushes the PU and requests
that prefetching begins from the stored recovery address.