[llvm] [X86] Prefer AVX512 VPCMP against zero over splat(1) for sle/slt (PR #216716)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 07:55:36 PDT 2026


================
@@ -58455,17 +58479,22 @@ static SDValue combineSetCC(SDNode *N, SelectionDAG &DAG,
           CmpKnown.Zero.isSignBitSet() || CmpKnown.One.isSignBitSet();
     }
     if (CanMakeSigned || ISD::isSignedIntSetCC(CC)) {
+      // AVX512 can encode LE/GE against zero; do not turn that into LT/GT
+      // vs ±1.
+      const bool KeepZeroCmp = Subtarget.hasAVX512() && VT.isVectorOf(MVT::i1);
       SDValue LHSOut = LHS;
       SDValue RHSOut = RHS;
       ISD::CondCode NewCC = CC;
       switch (CC) {
       case ISD::SETGE:
       case ISD::SETUGE:
         if (SDValue NewLHS = incDecVectorConstant(LHS, DAG, /*IsInc*/ true,
-                                                  /*NSW*/ true))
+                                                  /*NSW*/ true)) {
+          if (KeepZeroCmp && ISD::isConstantSplatVectorAllZeros(LHS.getNode()))
----------------
RKSimon wrote:

can we hoist this test before the incDecVectorConstant call to prevent unnecessary constant creations? same for below

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


More information about the llvm-commits mailing list