[llvm] [AArch64] Allow peephole to optimize AND + signed compare with 0 (PR #153608)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 09:11:38 PDT 2025


================
@@ -1921,7 +1998,8 @@ static bool canInstrSubstituteCmpInstr(MachineInstr &MI, MachineInstr &CmpInstr,
   // 1) MI and CmpInstr set N and V to the same value.
   // 2) If MI is add/sub with no-signed-wrap, it produces a poison value when
   //    signed overflow occurs, so CmpInstr could still be simplified away.
-  if (NZVCUsed->V && !MI.getFlag(MachineInstr::NoSWrap))
+  // 3) ANDS/BICS on AArch64 always sets V to 0, so it is safe to look through.
----------------
MacDue wrote:

I interpret `"MI and CmpInstr set N and V to the same value"` as meaning the values of `N` and `V` set by `MI` are the same as the values set by `CmpInstr`, not that `N == V`. 



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


More information about the llvm-commits mailing list