3 ms·
"Conditional move is superior on CPU" is an oversimplification, in reality it was explained in 2007 by Linus[1] and nothing changed since then. Or in fact, bran
by Lockal 2y ago
"Conditional move is superior on CPU" is an oversimplification, in reality it was explained in 2007 by Linus[1] and nothing changed since then. Or in fact, branch predictors are constantly improving[2], while cmov data dependency problem can't be solved. Yes, cmov is better in unpredictable branches, but the universal truth is "programmers are notoriously bad at predicting how their programs actually perform"[3]
[1] https://yarchive.net/comp/linux/cmov.html https://yarchive.net/comp/linux/cmov.html
[2] https://chipsandcheese.com/p/zen-5s-2-ahead-branch-predictor-unit-how-30-year-old-idea-allows-for-new-tricks https://chipsandcheese.com/p/zen-5s-2-ahead-branch-predictor...
[3] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fexpect https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index...
- account42 2y ago> cmov data dependency problem can't be solved Can't is a pretty strong word.
- TinkersW 2y agoI really only care about performance in a SIMD sense, as not using SIMD means you aren't targeting performance to begin with(GPU == SIMD, CPU SSE/AVX == SIMD) Branches fall off vs cmov/select as your lane count increases, they are still useful but only when you are certain the probability all lanes agreeing is reasonably high.