There is so many caveats to things like this, your trading a branch for a loop carried load data dependency, which is not always the same going to be the same cost, change the data set to be more predictable it becomes slower, change the condition to something more expensive it becomes slower.
Avoiding branches and doing obvious branch free programming like this is not always an easy win, the loop carried dependency is not free.
2
u/ReDucTor 13h ago
There is so many caveats to things like this, your trading a branch for a loop carried load data dependency, which is not always the same going to be the same cost, change the data set to be more predictable it becomes slower, change the condition to something more expensive it becomes slower.
Avoiding branches and doing obvious branch free programming like this is not always an easy win, the loop carried dependency is not free.