logoalt Hacker News

mcvtoday at 10:08 AM1 replyview on HN

Interesting. I thought modern CPU optimisation required avoiding branches, but here adding the branch allows the branch pediction to parallelise what it otherwise couldn't.


Replies

zipy124today at 11:03 AM

It does and the key here is that adding the if is akin to avoiding a branch, since getting data then doing something with it is a hidden branch if you already have the data. All this code does is formalise the hidden branch so that it can be avoided when possible.

show 2 replies