Global History Predictors
What you'll learn: How processors use a shared history of recent branch outcomes to predict branches more accurately by recognizing patterns across the entire program.
The Core Idea
So far you've learned predictors that track individual branches using their own counters (like two-bit saturating counters). But here's the insight: sometimes the outcome of one branch depends on what happened in other recent branches.
A Global History Predictor maintains a single shift register that records the outcomes (taken/not-taken) of the last N branches executed—regardless of which branch instructions they were. This creates a pattern of recent behavior that gets used to index into a table of prediction counters.
Why This Works
Think of it like predicting weather: knowing "it rained yesterday and the day before" helps predict today, even if those rain events happened in different locations. Similarly, branches in a program often follow correlated patterns.
For example:
if (x > 0) { ... } // Branch A
if (y > 0) { ... } // Branch B (might correlate with A)
If Branch A is taken, Branch B might be more likely to take a certain outcome. A global history predictor captures this.
How It Works
- Maintain a global history register (GHR): a bit vector of recent outcomes (e.g.,
1011= taken, not-taken, taken, taken) - Use the GHR pattern as an index into a pattern history table (PHT) of 2-bit saturating counters
- Each unique pattern gets its own counter
- After each branch resolves, shift the outcome into the GHR and update the corresponding counter
This captures correlations and repeating sequences that per-branch predictors miss.
Key Takeaway: Global History Predictors track recent branch outcomes across all branches to recognize correlated patterns and repeated sequences, improving prediction accuracy for programs with inter-branch dependencies.