Branch Prediction
Branch Prediction
Contents
1 Purpose of Branch Predictor 2
9 Conclusion 6
1
Introduction
Modern processors use branch prediction to minimize pipeline stalls caused by con-
ditional instructions (e.g., loops, if-else). In ARM processors, which power mobile and
embedded systems, branch prediction is a key feature for achieving high performance,
energy efficiency, and accuracy.
• Solution: Use branch prediction to predict the outcome and fetch instructions
speculatively.
Pipeline Delay
Without branch prediction, the processor stalls to determine the outcome of a branch:
Advantages:
• Simple to implement.
2
• No hardware overhead.
Limitations:
• Cannot adapt to branch behavior.
Role of BTB:
• Reduces latency by prefetching target instructions.
3
3.3 Global and Local Predictors
• Global History Register (GHR):
Example:
GHR = [T, T, N T, T ] (T: Taken, NT: Not-Taken)
2. Prediction Stage:
• Otherwise:
– Use static prediction.
3. Execution Stage:
4
5 ARMv8 and ARMv9 Enhancements
5.1 ARMv8-A (AArch64)
Key Features:
5.2 ARMv9
New Enhancements:
Correct Predictions
BPA = × 100
Total Branches
5
8 Example of Branch Prediction in ARM
8.1 Backward Branch in a Loop
MOV R0 , #0 ; I n i t i a l i z e counter
LOOP:
ADD R0 , R0 , #1 ; Increment c o u n t e r
CMP R0 , #10 ; Compare c o u n t e r w i t h 10
BNE LOOP ; Branch i f not e q u a l ( backward branch )
9 Conclusion
ARM processors use advanced branch prediction mechanisms to achieve high perfor-
mance, low latency, and energy efficiency. Techniques like dynamic prediction, neural
predictors, and hybrid models ensure ARM architectures excel in modern workloads.