Jump to content

Branchless Programming: Difference between revisions

no edit summary
No edit summary
Line 3: Line 3:
If the CPU predicts incorrectly, it will have to discard all pipelined results and go down the other route.
If the CPU predicts incorrectly, it will have to discard all pipelined results and go down the other route.
Furthermore warps on GPUs must all go through both branches if there are threads which go down each branch.
Furthermore warps on GPUs must all go through both branches if there are threads which go down each branch.
This can significantly slow things down.


In general, I consider avoiding if statements to be a micro-optimization.
In general, I consider avoiding if statements to be a micro-optimization.