🔀 Branch Predictor: gshare & 2-Bit Saturating Counters
Explore how modern CPUs guess the outcome of if-branches before they are resolved, using a gshare branch history table and 2-bit saturating counters to avoid costly pipeline flushes.
The simulation shows a gshare branch predictor tracking a loop's taken/not-taken pattern, updating 2-bit saturating counters and flushing the pipeline whenever a prediction turns out wrong.
🔬 What It Demonstrates
The simulation shows a gshare branch predictor tracking a loop's taken/not-taken pattern, updating 2-bit saturating counters and flushing the pipeline whenever a prediction turns out wrong.
🎮 How to Use
Step through loop iterations to watch the global history register shift, the indexed counter update, and use the controls to change the branch pattern or history length and see prediction accuracy respond.
💡 Did You Know?
Scott McFarling's original 1993 gshare paper used just a handful of history bits, yet the core XOR-indexing idea still underlies the far more elaborate TAGE predictors shipping in CPUs today.
Explore how modern CPUs guess the outcome of if-branches before they are resolved, using a gshare branch history table and 2-bit saturating counters to avoid costly pipeline flushes.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install