[llvm] [X86] Allow all legal integers to have optimize smin and smax with 0 (PR #151893)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 19:03:37 PDT 2025


================
@@ -25077,7 +25077,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
     } else if (SDValue R = LowerSELECTWithCmpZero(CmpOp0, Op1, Op2, CondCode,
                                                   DL, DAG, Subtarget)) {
       return R;
-    } else if ((VT == MVT::i32 || VT == MVT::i64) && isNullConstant(Op2) &&
+    } else if (VT.isScalarInteger() && isNullConstant(Op2) &&
                Cmp.getNode()->hasOneUse() && (CmpOp0 == Op1) &&
                ((CondCode == X86::COND_S) ||                    // smin(x, 0)
                 (CondCode == X86::COND_G && hasAndNot(Op1)))) { // smax(x, 0)
----------------
AZero13 wrote:

> hasAndNot returns false for i8/i16. Does this patch really affect smax?

For smax yes, not smin

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


More information about the llvm-commits mailing list