[llvm] [SelectionDAG] Improve ucmp/scmp codegen (PR #190787)

Takashi Idobe via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 25 06:19:04 PDT 2026


================
@@ -2767,6 +2752,13 @@ SDValue SelectionDAG::FoldSetCC(EVT VT, SDValue N1, SDValue N2,
       return getBoolConstant(ICmpInst::compare(C1, C2, getICmpCondCode(Cond)),
                              dl, VT, OpVT);
     }
+
+    // Fold setugt(X, 0) -> setne(X, 0): 0 is the minimum unsigned value,
+    // so X > 0 iff X != 0. This must be in FoldSetCC (not just SimplifySetCC)
+    // so the fold fires at construction time before expanded types like i128
+    // undergo multi-word comparison lowering.
+    if (OpVT.isInteger() && C2.isZero() && Cond == ISD::SETUGT)
----------------
Takashiidobe wrote:

Yup, removed that check.

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


More information about the llvm-commits mailing list