[llvm] [AArch64] Enable preferZeroCompareBranch for AArch64 (PR #145803)

David Green via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 5 10:57:16 PDT 2025


davemgreen wrote:

I'm not super sure either way, especially about the "has no drawbacks". Do you have any benchmark results?

Many cores can fuse cmp+branch together, and it looks like this will transform
```
  //  %c = icmp ult %x, 8
  //  br %c, bla, blb
  //  %tc = lshr %x, 3
  // to
  //  %tc = lshr %x, 3
  //  %c = icmp eq %tc, 0
  //  br %c, bla, blb
```
We don't have lshr that sets flags like we do for Arm, but do have a cbz. The branch might happen later, but the codesize is likely smaller.

https://github.com/llvm/llvm-project/pull/145803


More information about the llvm-commits mailing list