3 ms·
It's a simple rule of thumb to avoid branching in performance-critical code. Branchless code is pretty predictable, but if branching takes place, one can no lon
by Panzerschrek 1y ago
It's a simple rule of thumb to avoid branching in performance-critical code. Branchless code is pretty predictable, but if branching takes place, one can no longer reason so easy about code performance, since compiler optimizations and CPU branch prediction may be involved.
- account42 1y agoBut reality is not that simple. Branchless with unfortunate data dependencies can be a lot worse than predictable branching code.
- Panzerschrek 1y agoThat's why I said it's a rule of thumb. There are always exceptions where branching does code faster.