3 ms·
Branch prediction is already extremely efficient for loops, it simply assumes the last comparison will be the same. For loops this is true for all but the first
by petjuh 11y ago
Branch prediction is already extremely efficient for loops, it simply assumes the last comparison will be the same. For loops this is true for all but the first and last iteration.
- SamReidHughes 11y agoEven if it's perfect it still takes up branch prediction overhead in the processor, and hurts the performance of other branches. Also, getting the first or last iteration wrong is pretty bad for a ton of for loops out there.