[llvm] 9d4fbcd - Revert "[SLP]Fix PR63141: compareCmp is not strict weak ordering."

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 04:37:41 PDT 2023


Author: Alexey Bataev
Date: 2023-06-28T04:37:27-07:00
New Revision: 9d4fbcd5ffa79a0632a6eab4ce0d495a7bb9c276

URL: https://github.com/llvm/llvm-project/commit/9d4fbcd5ffa79a0632a6eab4ce0d495a7bb9c276
DIFF: https://github.com/llvm/llvm-project/commit/9d4fbcd5ffa79a0632a6eab4ce0d495a7bb9c276.diff

LOG: Revert "[SLP]Fix PR63141: compareCmp is not strict weak ordering."

This reverts commit f3ebd88064d7f1c36a8272b3e5f7d53501c3f53b to pacify
windows-based buildbots.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
    llvm/test/Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred-parent.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b6a75fb2df231..3416e953e099b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14413,12 +14413,9 @@ static bool tryToVectorizeSequence(
 /// of the second cmp instruction.
 template <bool IsCompatibility>
 static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
-                       const DominatorTree &DT,
                        function_ref<bool(Instruction *)> IsDeleted) {
   auto *CI1 = cast<CmpInst>(V);
   auto *CI2 = cast<CmpInst>(V2);
-  if (IsDeleted(CI1) || !isValidElementType(CI1->getType()))
-    return true;
   if (IsDeleted(CI2) || !isValidElementType(CI2->getType()))
     return false;
   if (CI1->getOperand(0)->getType()->getTypeID() <
@@ -14449,27 +14446,12 @@ static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
       return false;
     if (auto *I1 = dyn_cast<Instruction>(Op1))
       if (auto *I2 = dyn_cast<Instruction>(Op2)) {
-        if (IsCompatibility) {
-          if (I1->getParent() != I2->getParent())
-            return false;
-        } else {
-          // Try to compare nodes with same parent.
-          DomTreeNodeBase<BasicBlock> *NodeI1 = DT.getNode(I1->getParent());
-          DomTreeNodeBase<BasicBlock> *NodeI2 = DT.getNode(I2->getParent());
-          if (!NodeI1)
-            return NodeI2 != nullptr;
-          if (!NodeI2)
-            return false;
-          assert((NodeI1 == NodeI2) ==
-                     (NodeI1->getDFSNumIn() == NodeI2->getDFSNumIn()) &&
-                 "Different nodes should have 
diff erent DFS numbers");
-          if (NodeI1 != NodeI2)
-            return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
-        }
+        if (I1->getParent() != I2->getParent())
+          return false;
         InstructionsState S = getSameOpcode({I1, I2}, TLI);
-        if (S.getOpcode() && (IsCompatibility || !S.isAltShuffle()))
+        if (S.getOpcode())
           continue;
-        return !IsCompatibility && I1->getOpcode() < I2->getOpcode();
+        return false;
       }
   }
   return IsCompatibility;
@@ -14496,14 +14478,14 @@ bool SLPVectorizerPass::vectorizeCmpInsts(iterator_range<ItT> CmpInsts,
   // Try to vectorize list of compares.
   // Sort by type, compare predicate, etc.
   auto CompareSorter = [&](Value *V, Value *V2) {
-    return compareCmp<false>(V, V2, *TLI, *DT,
+    return compareCmp<false>(V, V2, *TLI,
                              [&R](Instruction *I) { return R.isDeleted(I); });
   };
 
   auto AreCompatibleCompares = [&](Value *V1, Value *V2) {
     if (V1 == V2)
       return true;
-    return compareCmp<true>(V1, V2, *TLI, *DT,
+    return compareCmp<true>(V1, V2, *TLI,
                             [&R](Instruction *I) { return R.isDeleted(I); });
   };
 

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred-parent.ll b/llvm/test/Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred-parent.ll
index a2a79bf53da25..1e11a01f9774f 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred-parent.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred-parent.ll
@@ -39,10 +39,10 @@ define void @test1() {
 ; CHECK-NEXT:    br label [[BB:%.*]]
 ; CHECK:       bb:
 ; CHECK-NEXT:    [[CALL37:%.*]] = load i16, ptr poison, align 2
-; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 poison, i16 poison, i16 poison, i16 poison, i16 0>, i16 [[CALL]], i32 3
-; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[CALL37]], i32 4
-; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 7>
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 poison, i16 poison>, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 3, i32 4>
+; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 poison, i16 poison, i16 0, i16 poison, i16 poison>, i16 [[CALL37]], i32 3
+; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[CALL]], i32 7
+; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 3, i32 5, i32 3, i32 7>
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 poison, i16 poison, i16 0>, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 3, i32 7, i32 15>
 ; CHECK-NEXT:    [[TMP4:%.*]] = icmp slt <8 x i16> [[TMP2]], [[TMP3]]
 ; CHECK-NEXT:    ret void
 ;


        


More information about the llvm-commits mailing list