[llvm] [AArch64] Improve lowering of scalar abs(sub(a, b)). (PR #151180)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 04:23:43 PDT 2025


================
@@ -25464,6 +25467,24 @@ static SDValue performCSELCombine(SDNode *N,
     }
   }
 
+  // CSEL a, b, cc, SUBS(SUB(x,y), 0) -> CSEL a, b, cc, SUBS(x,y) if cc doesn't
+  // use overflow flags to avoid the comparison with zero.
+  if (Cond.getOpcode() == AArch64ISD::SUBS &&
+      isNullConstant(Cond.getOperand(1))) {
----------------
paulwalker-arm wrote:

Sounds reasonable to me.

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


More information about the llvm-commits mailing list