HomeComputer ScienceBranch Predictor: gshare & 2-Bit Saturating Counters

🔀 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.

Computer Science3DModerate60 FPS
branch-predictor-gshare-lab ↗ Open standalone

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.

⚙ Under the hood

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.

computer-architecturebranch-predictiongsharecpu-pipelinemicroarchitectureperformanceprocessor-design

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)