Assembly branch instructions, are conditional jumps. There are two paths to follow, the one that the condition holds and the opposite one.
- CPU can predict the path with
@branch(.none)or not a@branchhint at all. @branch(.likely)means that this path is likely to be reached.@branch(.unlikely)means that this path is unlikely to be reached.@branch(.cold)means that this path is unlikely to ever be reached.@branch(.unpredictable)means that it is difficult to predict if this path is reached or not.
For example:
i = 1000;
while (i > 0) {
i -= 1;
...
}
The statements inside while are .likely because they run 999 times, the other path (to skip while) is .unlikely because it runs only one time.