2 Comments

It doesn't make sense to use branchless programming the vast majority of the time. As you stated, it improves performance, but at the cost of complexity - and the cost of complexity far outweighs the benefits to performance.

At least most of the time. Where the optimizations of branchless programming are useful is in the (usually very small) areas of code where performance bottlenecks are known to exist.

Implementing these techniques in just a few key places will have an outsized impact on performance.

And since these areas are small, we can put more time into commenting them extensively so it's clear to those who follow in our slime trai... uh, footsteps, what the code is doing.

So, this all means that, as in literally every other cool new programming fad/idea, branchless programming has application in specific circumstances, but isn't a panacea. A truly professional programmer needs to choose the appropriate technique for the specific circumstances at hand, not try to hammer the round pegs of a favored technique into the square holes of reality.

Expand full comment
author

"A truly professional programmer needs to choose the appropriate technique for the specific circumstances at hand, not try to hammer the round pegs of a favored technique into the square holes of reality."

That's something I try to get across through my writing. Develop judgement, don't just focus on the techniques

Expand full comment