The Branch Not Taken

by Vince Weaver
(with apologies to Robert Frost)
A branch diverged in CPU,
And hardware could not follow both.
Wasted cycles, nearly fifty-two
If pipeline flushed and started anew
Thus wasting all the Moore's law growth.  5
 
This branch is forward, a jump out there
Beyond the RAM this cacheline claimed
Into the void where pointers dare.
In contrast the fallthrough is fair;
Wanting to follow cannot be blamed.  10
 
But a context switch recently gave
The predictor an untrained state.
Taking the branch could be too brave -
Only the compiler our skin can save -
With wise decisions so we will not wait.  15
 
Hopefully seen as the right thing to do
Somewhere cycles and cycles hence:
A branch diverged, and the CPU
Predicted it not-taken
And that has made all the difference  20
 
  - at least on the SPECint benchmarks.