Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@nigger @Ghislaine No.
When you execute instructions on a modern CPU it goes through this thing called a "pipeline." Essentially instead of executing one instruction at once, it executes part of 5-20 instructions at once. When one of those instructions is a conditional branch, this has the impact of potentially flushing out the entire pipeline because a lot of those partially executed instructions are invalid, which slows the computer down!
Branch prediction allows you to mitigate the impact of that - if you know how you're going to branch, you can pick the right set of instructions to feed through the pipeline most of the time, which is good enough for a substantial performance improvement. You don't need it to be perfect, you just need it to be cheap and better than nothing.