Source

Branch

1/ @andrecasaldev

The key here is that CPUs mostly only have two options:

  1. Assume the branch will occur and read the instruction it points to
  2. Assume the branch will not occur and read the instruction below it

Either way, if the CPU predicted wrong, it will have to discard the instruction and go read the correct one, losing performance.

Branchless programming is fascinating, even if not always very clear 😁