Branch Prediction

Updated: 04/26/2017 by Computer Hope

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" what condition is most likely to be met. It then executes the operations required by the most likely result ahead of time so that they are already complete if and when the guess was correct. At runtime, if the guess turns out not to have been 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