Branch misprediction occurs when a CPU mispredicts the next instruction to process in branch prediction, which is aimed at speeding up execution. Jump to: navigation, search This article needs to be cleaned up to conform to a higher standard of quality. ... In computer architecture, a branch predictor is the part of a processor that determines whether a conditional branch in the instruction flow of a program is likely to be taken or not. ...
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. In computer architecture, a branch predictor is the part of a processor that determines whether a conditional branch in the instruction flow of a program is likely to be taken or not. ...
The branch prediction unit is adapted to generate branch predictions for the branch instructions, direct the instruction fetch unit to retrieve the program instructions in an order corresponding to the branch predictions, and redirect the instruction fetch unit based on a branchmisprediction.
The goal of the branch prediction unit 30 is to identify and predict the outcome of branch instructions such that the instruction fetch unit 20 may retrieve the program instructions required by the execution engine 15 in advance.
After a mispredictedbranch instruction, instructions entered into the pipeline subsequent to the mispredictedbranch instruction are flushed, and the pipeline is reloaded from the redirect instruction address stored in the branch resolution table 45.
As a result of the misprediction, both the taken branch, represented by instructions 3 and 4, and the untaken branch, represented by instructions 1 and 2, are fetched.
This is orthogonal to the case where several branches and their target reappear in the instruction windows, such as the case of a conditional branch within a loop, in which each new occurrence of a target resolves the last occurrence of the branch.
Regardless of whether the branch was correctly predicted or not, and whether the detection of the alternative branch succeeded or not, the ABAT entry corresponding to the branch is always dismissed once the branch is committed.