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

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 22 03:18:10 PST 2025


================
@@ -26417,6 +26418,11 @@ static SDValue performSETCCCombine(SDNode *N,
       return DAG.getNode(ISD::SETCC, DL, VT, TST, RHS, N->getOperand(2));
     }
   }
+  if (Subtarget->hasCSSC() && Cond == ISD::SETNE && isNullConstant(RHS)) {
+    SDValue One = DAG.getConstant(1, DL, LHS.getValueType());
+    auto UMin = DAG.getNode(ISD::UMIN, DL, LHS.getValueType(), LHS, One);
+    return DAG.getNode(ISD::TRUNCATE, DL, MVT::i1, UMin);
+  }
----------------
MacDue wrote:

This seems to assume the result of `SETCC` is always an `i1`, but I think it can be a vector or other integer type. 

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


More information about the llvm-commits mailing list