Branch prediction: ==speculatively fetch the next instruction from one of the branches. We could fetch either instr C or instr E and hope we fetch the correct one. If we guess wrong, data has to be removed from registers==.

To pick the correct branch (in branch prediction), we can choose a few options: ?

  • We could pick randomly, yielding 50% success rate.
  • Could use static prediction, hence analyse the code at compile-time, yielding 80% success rate on average. (from SPEC analysis)
  • Use dynamic prediction: during run-time keep track of how often each branch is taken and when the conditional is encountered in the future, fetch the most common branch. This does require some training ahead of time.