r/programming 1d ago

Branch‑Avoidant Programming

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

87 comments sorted by

View all comments

142

u/meamZ 1d ago

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...

3

u/VoodaGod 22h ago

and how can you tell predictability?

2

u/andrewpiroli 21h ago

Most profilers will have an option to track branch predictor hits and misses. I know AMD uProf and Apple Instruments do. and there are Linux perf events for it as well.