CPU Design · All levels

Branch Prediction & Speculation

Prediction structures and recovery behavior that control wrong-path cost and front-end stability.

Section goal

Prediction structures and recovery behavior that control wrong-path cost and front-end stability.

How to study this section

  1. Start with each topic hub to establish mechanism-first framing.

  2. Use reports and debug pages to separate symptoms from root cause.

  3. Practice worked examples and interview drills under fixed metadata.

  4. Close with checklist and silicon impact before signoff claims.

Topics

  1. predictor-types-and-accuracy/ - Predictor Types and Accuracy

  2. btb-and-return-stack/ - BTB and Return Stack

  3. indirect-branch-prediction/ - Indirect Branch Prediction

  4. mispredict-penalty-recovery/ - Mispredict Penalty and Recovery

Related topics

CPU deep dive

Speculation helps only when wrong-path cost and recovery bandwidth are tightly controlled.

Concept diagram

diagram
SPECULATION LOOP

predict direction/target -> speculative fetch/decode -> resolve -> flush/recover

Metric graph

diagram
SPECULATION COST MIX

wrong-path decode work  █████
flush recovery delay    ████
refill starvation       ███

Reports and artifacts

  • branch accuracy by workload

  • BTB/RAS pressure report

  • mispredict recovery timeline

  • bad-speculation CPI share

Mini case study

Indirect branch aliasing in one service raised wrong-path work enough to dominate total CPI despite high ALU utilization.

Debug branches

  • Break down mispredicts by branch family and code region

  • Measure flush depth and refill bandwidth separately

  • Validate predictor changes under security mitigation settings

Senior review question

Ask: which CPI/latency evidence proves this topic is truly closed beyond synthetic benchmarks?