8 ms·
LLVM recently introduced a SelectOptimize pass, which is used for select -> branch conversion in the presence of PGO information. This should replace the curren
by nikic 4y ago
LLVM recently introduced a SelectOptimize pass, which is used for select -> branch conversion in the presence of PGO information. This should replace the current non-PGO-aware X86 cmov conversion pass.
The result of this should be that without PGO cmov is preferred, which is the right default (incorrectly picking a cmov is a bit worse than picking a branch, incorrectly picking a branch is catastrophically worse than picking a cmov).
- jabl 4y agoIs it the right default? If the vast majority of branches are predictable, then without PGO a branch would be the right choice, no? If they're gonna make this behavior the default, I presume they have lots of benchmarks showing it's generally the correct choice..
- pclmulqdq 4y agoThe vast majority of branches don't fit in the branch predictor, so it is taking no more than a naive guess about them. If you tell LLVM that the branch is likely or unlikely, they shouldn't use a CMOV, and should instead lay out the code so that the naive branch predictor is correct most of the time. Otherwise, the CMOV actually is likely to be beneficial.