Comment by grumbelbart2

15 hours ago

There is a static branch predictor that is used if there is no statistic on a branching instruction yet, and it's really simple: Jumps backward are assumed to be taken (they usually are from a loop), jumps forward are assumed to be not taken.

So the jump that forms the loop will be predicted correctly for all executions but the very last (when the loop ends).

That's very cute.

I wonder how much more complicated and effective statistical predictors are.

  • They get much more complicated, but their effectiveness tops out where certain branches just can’t be predicted in advance.