3 ms·
I'm a noob. Looking at the disasm: https://godbolt.org/z/766aPTPc3 https://godbolt.org/z/766aPTPc3 It turns a CMOVQLT to a JLT. Is the blog saying CMOVQLT don't
by zhzy0077 3y ago
I'm a noob. Looking at the disasm: https://godbolt.org/z/766aPTPc3 https://godbolt.org/z/766aPTPc3
It turns a CMOVQLT to a JLT. Is the blog saying CMOVQLT don't have branch predication?
I don't get it.
- ludiludi 3y agoYour disasm is for x86-64. The benchmarks in the blog were run on an M1 MacBook Pro, which is an ARM64.
- zhzy0077 3y agoSorry. My bad. But looking at ARM64 https://godbolt.org/z/YEjGKce1Y https://godbolt.org/z/YEjGKce1Y The difference is CSEL and BLT. The question still stands. Does CSEL have no branch predication?
- ludiludi 3y agoIt appears so. https://developer.arm.com/documentation/102374/0101/Program-flow---conditional-select-instructions https://developer.arm.com/documentation/102374/0101/Program-... "So far, we have seen examples that use branches to handle decisions. The A64 instruction set also provides conditional select instructions. In many cases, these instructions can be used as an alternative to branches." Seems CSEL is not a branch.
- masklinn 3y agoCSEL is a conditional move, they’re usually used to avoid branches (and branch predication) entirely. Here it turns out to be a very bad choice, because it creates unnecessary data dependencies. But a cmov would be a fine choice if the branch was impossible to predict (e.g. if the input was random, well even then I’d expect the limit to mostly creep up so it should be predicated as mostly cold).