Branch misprediction

From Wikipedia, the free encyclopedia

Branch misprediction occurs when a Central processing unit (CPU) mispredicts the next instruction to process in branch prediction, which is aimed at speeding up execution.

During the execution of certain programs there are places where the program execution flow can continue in several ways. These are called branches, or conditional jumps. The CPU also uses a pipeline which allows several instructions to be processed at the same time. When the code for a conditional jump is read we do not yet know the next instruction to execute and insert into the execution pipeline. This is where branch prediction comes in. Branch prediction guesses the next instruction to execute and inserts the next assumed instruction to the pipeline. Guessing wrong is called branch misprediction. This causes the work done to start processing the instructions following the branch to be discarded. If this happens too often it can hinder performance.