|
|
Intel BlogsWhitepapers
|
Branch and loop reorganization to prevent misdirectsHow the Microprocessor Works Block Diagram: Microprocessors use various branch-prediction methods to keep from making mistakes when they encounter a conditional branch during instruction execution. There are, however, proven techniques to minimize branch misdirection and keep deeply pipelined processors fully utilized.
by Jeff Andrews, application engineer, Intel Corp. Proven techniques and Intel tools enable developers to minimize branch mispredictions and keep deep-pipelined processors fully utilized. Modern microprocessors are pipelined in order to get more instructions completed faster. This means that instructions do not wait for the previous ones to complete before their execution begins. A problem with this approach arises, however, due to conditional branches. If the microprocessor encounters a conditional branch and the result for the condition has not yet been calculated, how does it know whether to take the branch or not? This is where branch prediction comes in. Branch prediction is what the processor uses to decide whether to take a conditional branch or not. Getting this information as accurately as possible is important, as an incorrect prediction (mispredict) will cause the microprocessor to throw out all the instructions that did not need to be executed and start over with the correct set of instructions. This process is particularly expensive with deeply pipelined processors. This article introduces the various branch-prediction methods used by the microprocessor and provides some tips about how to avoid costly mispredicts. The paper assumes that the reader is familiar with programming in C and with IA32 assembly-language instructions.
Branch examples The first type of construction considered here that causes conditional branches is if-else :
Subscribers who liked this article also read:
If you're interested in this topic, these articles may be helpful:
Related Jobs: |
|
|