Skip to main content
Definition Website Computer and Technology

Branch Prediction

Subject: Computer and Technology noun /ˈbræntʃ prɪˈdɪk.ʃən/ 1 definition

  1. Definition (noun)

    Entry #105 · Updated

    Branch Prediction is a processor microarchitecture technique in pipelined CPUs that anticipates the direction and target address of a branch instruction before its condition is evaluated. Without prediction, the instruction-fetch stage would have to stall on every conditional jump or indirect call until earlier instructions finished computing the outcome, leaving execution units idle. By speculatively fetching and executing instructions along the most likely path, branch prediction keeps deep pipelines saturated when predictions succeed, while requiring the processor to flush uncommitted speculative work and restart from the true target whenever a misprediction occurs.

    Common Types

    • Static Branch Prediction: Applies fixed compile-time or decode-time heuristics—such as assuming backward loop branches are taken and forward branches are not taken—without tracking runtime execution history.

    • Dynamic Local Prediction: Uses on-chip tables of saturating counters, such as a Branch History Table (BHT), to track an individual branch instruction's recent outcomes and tolerate occasional exceptions in steady patterns.

    • Global and Hybrid Prediction: Correlates recent branch outcomes across the program using a global history register—often combining multiple predictors in a tournament or TAGE scheme—to capture interdependent conditional logic.

    • Target and Return Stack Prediction: Pairs a Branch Target Buffer (BTB) and a hardware Return Address Stack (RAS) with direction predictors to anticipate destination addresses for indirect jumps, virtual method calls, and function returns.

    Example

    When a compiled loop scans an array of one million integers with a conditional branch that sums only values above a threshold, a modern CPU's dynamic predictor learns the long runs of taken and not-taken outcomes on sorted data and keeps the pipeline fed speculatively. On unsorted random data, that branch mispredicts roughly half the time, triggering repeated pipeline flushes that make the loop substantially slower despite executing the same instruction count.