Course contentsShow
← Computer Science
Lesson 1182 of 2,87227. Pipelining and PerformanceFree lesson

Local History Predictors

Per-branch history tables tracking individual branch patterns independently for loop and repeated structures.

Local History Predictors

What you'll learn: How processors track the behavior of individual branches using their own dedicated history to predict loops and repeated patterns more accurately.

The Core Idea

While global history predictors (from the previous lesson) track one shared history of all recently executed branches, local history predictors maintain a separate history table for each branch instruction in your program.

Think of it like tracking personal habits: instead of saying "people generally eat lunch at noon," you track that you specifically eat at 12:15, your friend eats at 11:45, and your colleague skips lunch. Each person (branch) gets their own pattern record.

How It Works

Each branch's Program Counter (PC) serves as an index into a table. That table entry stores:

  • A short history of that specific branch's recent outcomes (e.g., last 4 taken/not-taken decisions)
  • This local history then indexes into a Pattern History Table (PHT) of 2-bit saturating counters

For example, if a branch at address 0x4008 has gone "Taken, Taken, Not-Taken, Taken" (pattern 1101), the predictor uses that exact pattern to look up a confidence counter and make a prediction.

Why This Matters

Local history predictors excel at loops and correlated branches where the same instruction behaves predictably but differently from other branches. A loop counter branch will show patterns like "TTTTTNTTTTTN" (taken many times, not-taken to exit). By tracking this branch alone, the predictor learns its unique rhythm without interference from unrelated branches elsewhere in the code.

Key Takeaway: Local history predictors assign each branch its own pattern tracker, enabling precise prediction of repetitive structures like loops by learning individual branch behavior independently.