CPUs and architecture

What is the purpose of branch prediction in a CPU?

  1. ATo predict the outcome of branch instructions and execute ahead, reducing pipeline stalls
  2. BTo predict power consumption and control the power supply
  3. CTo predict main memory capacity
Show answer and explanation

Answer: A. To predict the outcome of branch instructions and execute ahead, reducing pipeline stalls

In a pipeline, the next instruction is unknown until a branch resolves, stalling progress. Branch prediction guesses the outcome from past history and proceeds speculatively, redoing work only when wrong. In typical programs roughly one in five instructions is a branch, so the impact is large; high-performance CPUs predict with very high accuracy. Each misprediction can cost over a dozen to about twenty cycles, so even small accuracy gains matter.