Branch prediction is a technique used in CPU design that attempts to guess the outcome of a conditional operation and prepare for the most likely result. A digital circuit that performs this operation is known as a branch predictor. It is an important component of modern CPU architectures, such as the x86.

How does it work?

When a conditional operation such as an if…else statement needs to be processed, the branch predictor “speculates” which condition most likely will be met. It then executes the operations required by the most likely result ahead of time. This way, they’re already complete if and when the guess was correct. At runtime, if the guess turns out not to be correct, the CPU executes the other branch of operation, incurring a slight delay. But if the guess was correct, speed is significantly increased.

The first time a conditional operation is seen, the branch predictor does not have much information to use as the basis of a guess. But the more frequently the same operation is used, the more accurate its guess can become.

CPU terms

  • How to determine the type and speed of a processor.
  • CPU help and support.