Re:Decimating Array.Sort with AVX2
by throwaway_pdp09 on Sunday May 24, 2020 @09:11AM
(#23291246)
That was a dumb oversight on my part not to think to mention this vital point. Thanks. (also thanks for SETcc, I didn't know of this instruction)
"Use the SETCC and CMOV instructions to eliminate unpredictable conditional branches where possible. Do not do this for predictable branches. Do not use these instructions to eliminate all unpredictable conditional branches (because using these instructions will incur execution overhead due to the requirement for executing both paths of a conditional branch). In addition, converting a conditional branch to SETCC or CMOV trades off control flow dependence for data dependence and restricts the capability of the out-of-order engine. When tuning, note that all Intel 64 and IA-32 processors usually have very high branch prediction rates. Consistently mispredicted branches are generally rare. Use these instructions only if the increase in computation time is less than the expected cost of a mispredicted branch."
NB: Intel is recommending CMOV for unpredictable branches. For well predictable branches, they're recommending ... branches.
[1] https://yarchive.net/comp/linux/cmov.html