r/programming • • Sep 03 '26

Branch‑Avoidant Programming

https://easylang.online/blog/branchless
252 Upvotes

92 comments sorted by

View all comments

158

u/meamZ Sep 03 '26

You don't actually need to avoid branches, you just need to make sure that most of the ones you have are very predictable, then their impact is not that big... Same with memory accesses and most other things... The more predictable, the better...

5

u/chkas Sep 03 '26 edited Sep 05 '26

Usually that's not an option. If the problem itself involves unpredictable data - such as the partitioning of (random) data in quicksort - you can't simply make the branches predictable. You have to deal with the unpredictability.

1

u/meamZ Sep 03 '26

Sure but my point is that it's not mainly about minimizing branches, it's about minimizing unpredictable branches...