In computer architecture, a branch predictor is a digital
Added on - 20 Sep 2019
Incomputer architecture, abranch predictoris adigital circuitthat tries toguess which way abranch(e.g. anif-then-else structure) will go before this is knownfor sure. The purpose of the branch predictor is to improve the flow in theinstructionpipeline. Branch predictors play a critical role in achieving higheffectiveperformancein many modernpipelinedmicroprocessorarchitectures suchasx86.Figure 1: Example of 4-stage pipeline. The colored boxes represent instructionsindependent of each otherTwo-way branching is usually implemented with aconditionaljumpinstruction. A conditional jump can either be "not taken" and continueexecution with the first branch of code which follows immediately after theconditional jump, or it can be "taken" and jump to a different place in programmemory where the second branch of code is stored. It is not known for certainwhether a conditional jump will be taken or not taken until the condition has beencalculated and the conditional jump has passed the execution stage in the instructionpipeline (see fig. 1).Without branch prediction, the processor would have to wait until theconditional jump instruction has passed the execute stage before the next instructioncan enter the fetch stage in the pipeline. The branch predictor attempts to avoid thiswaste of time by trying to guess whether the conditional jump is most likely to betaken or not taken. The branch that is guessed to be the most likely is then fetchedandspeculatively executed. If it is later detected that the guess was wrong then thespeculatively executed or partially executed instructions are discarded and thepipeline starts over with the correct branch, incurring a delay.