Gshare and Pshare Branch Predictors
Gshare and Pshare Branch Predictors
Predictors: A Comprehensive
Analysis
Branch prediction is crucial for high-performance superscalar and out-of-order processors.
Two widely used index-sharing predictors are Gshare and Pshare, both of which attempt
to improve accuracy while managing aliasing in Pattern History Tables (PHTs).
1. Branch History Register (BHR) stores recent branch outcomes (e.g., last 12
branches).
2. The lower bits of the program counter (PC) are XORed with the BHR.
3. The result is used to index the PHT, which contains 2-bit saturating counters for
branch predictions.
4. The PHT counter updates based on actual branch behavior, adjusting over time.
📌 Key Idea: XORing spreads out PHT index entries more evenly, reducing aliasing
conflicts.
📌 Pros of Gshare
✔ Better utilization of PHT entries: The XOR operation reduces destructive aliasing
compared to GAg.
✔ Effective for correlated branches: Captures global branch behavior efficiently.
✔ Simple implementation: Only modifies the index function, making it hardware-
friendly.
❌ Cons of Gshare
✖ Not ideal for local branch patterns: Since it uses global history, it may fail for
branches that are locally dependent.
✖ Increased indexing complexity: The XOR operation adds latency, impacting access
speed in deep pipelines.
✖ Aliasing still exists: While less than GAg, some branches still overwrite each other's
history.
📌 Key Idea: Instead of relying on a single global history, Pshare tracks each branch
individually.
📌 Pros of Pshare
✔ Less interference between different branches: Since each branch stores its own history,
there is less aliasing compared to Gshare.
✔ Better for loops and repetitive patterns: Works well when a branch is dependent on its
own previous executions.
✔ More accurate in localized patterns: Avoids mixing up unrelated branch histories.
❌ Cons of Pshare
✖ Higher storage cost: Each branch needs its own BHT entry, consuming more memory
than Gshare.
✖ Poor at capturing global correlations: If a branch depends on other branches'
outcomes, Pshare fails to predict accurately.
✖ More complex hardware implementation: Since each branch address maintains a
separate history register, BHT lookups increase latency.
1. Jiménez & Lin (2003) - "Neural Methods for Dynamic Branch Prediction"
oThis paper compared Gshare and Perceptron-based predictors and found
that Perceptron predictors outperform Gshare for linearly separable
branches.
2. Tendler et al. (2002) - "IBM Power4 Architecture"
o Describes how IBM POWER4 used global-history and per-address branch
predictors in a hybrid approach.
3. Seznec et al. (2006) - "The TAGE Predictor"
o TAGE (TAgged GEometric) predictors improve upon Gshare by using
multiple tables with varying history lengths.
In the future, branch prediction will likely evolve to include AI-driven and statistical
models, further reducing misprediction penalties in deep pipelines. 🚀