[llvm] [AArch64] Use umin for x != 0 when +cssc is enabled (PR #169159)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 06:59:18 PST 2025


================
@@ -11735,7 +11735,12 @@ SDValue AArch64TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
   }
 
   if (LHS.getValueType().isInteger()) {
-
+    if (Subtarget->hasCSSC() && CC == ISD::SETNE && isNullConstant(RHS)) {
+      SDValue One = DAG.getConstant(1, DL, LHS.getValueType());
+      auto UMin = DAG.getNode(ISD::UMIN, DL, LHS.getValueType(), LHS, One);
+      SDValue Res = DAG.getNode(ISD::TRUNCATE, DL, VT, UMin);
----------------
MacDue wrote:

nit: Avoid `auto` here and maybe use `getZExtOrTrunc`.
```suggestion
      SDValue UMin = DAG.getNode(ISD::UMIN, DL, LHS.getValueType(), LHS, One);
      SDValue Res = DAG.getZExtOrTrunc(UMin, DL, VT);
```

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


More information about the llvm-commits mailing list