[llvm] 31845cf - Revert "[SLP]Fix non-determinism in reused elements analysis"
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 6 08:59:16 PST 2025
Author: Alexey Bataev
Date: 2025-03-06T08:59:08-08:00
New Revision: 31845cf06c2b1555a0bcf6adc116cc17469978e5
URL: https://github.com/llvm/llvm-project/commit/31845cf06c2b1555a0bcf6adc116cc17469978e5
DIFF: https://github.com/llvm/llvm-project/commit/31845cf06c2b1555a0bcf6adc116cc17469978e5.diff
LOG: Revert "[SLP]Fix non-determinism in reused elements analysis"
This reverts commit 3158525afdc3677457712963ef45c83f4f8f900f to fix
a bug revealed in https://lab.llvm.org/buildbot/#/builders/123/builds/14930
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
llvm/test/Transforms/SLPVectorizer/X86/buildvectors-with-same-parents.ll
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a44bfe0dfd74a..3bb8e38905aae 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3801,7 +3801,7 @@ class BoUpSLP {
SetVector<const TreeEntry *> PostponedGathers;
using ValueToGatherNodesMap =
- DenseMap<Value *, SmallSetVector<const TreeEntry *, 4>>;
+ DenseMap<Value *, SmallPtrSet<const TreeEntry *, 4>>;
ValueToGatherNodesMap ValueToGatherNodes;
/// A list of the load entries (node indices), which can be vectorized using
@@ -8328,15 +8328,14 @@ class PHIHandler {
}
return;
}
- SmallMapVector<std::pair<BasicBlock *, unsigned>, SmallVector<unsigned>, 4>
- Blocks;
- for (unsigned I : seq<unsigned>(Main->getNumIncomingValues())) {
+ SmallDenseMap<BasicBlock *, SmallVector<unsigned>, 4> Blocks;
+ for (unsigned I : seq<unsigned>(0, Main->getNumIncomingValues())) {
BasicBlock *InBB = Main->getIncomingBlock(I);
if (!DT.isReachableFromEntry(InBB)) {
Operands[I].assign(Phis.size(), PoisonValue::get(Main->getType()));
continue;
}
- Blocks.try_emplace(std::make_pair(InBB, I)).first->second.push_back(I);
+ Blocks.try_emplace(InBB).first->second.push_back(I);
}
for (auto [Idx, V] : enumerate(Phis)) {
if (isa<PoisonValue>(V)) {
@@ -8345,7 +8344,7 @@ class PHIHandler {
continue;
}
auto *P = cast<PHINode>(V);
- for (unsigned I : seq<unsigned>(P->getNumIncomingValues())) {
+ for (unsigned I : seq<unsigned>(0, P->getNumIncomingValues())) {
BasicBlock *InBB = P->getIncomingBlock(I);
if (InBB == Main->getIncomingBlock(I)) {
if (isa_and_nonnull<PoisonValue>(Operands[I][Idx]))
@@ -8353,18 +8352,17 @@ class PHIHandler {
Operands[I][Idx] = P->getIncomingValue(I);
continue;
}
- auto *It = Blocks.find(std::make_pair(InBB, I));
+ auto It = Blocks.find(InBB);
if (It == Blocks.end())
continue;
Operands[It->second.front()][Idx] = P->getIncomingValue(I);
}
}
for (const auto &P : Blocks) {
- ArrayRef<unsigned> IncomingValues = P.second;
- if (IncomingValues.size() <= 1)
+ if (P.getSecond().size() <= 1)
continue;
- unsigned BasicI = IncomingValues.front();
- for (unsigned I : IncomingValues.drop_front()) {
+ unsigned BasicI = P.getSecond().front();
+ for (unsigned I : ArrayRef(P.getSecond()).drop_front()) {
assert(all_of(enumerate(Operands[I]),
[&](const auto &Data) {
return !Data.value() ||
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/buildvectors-with-same-parents.ll b/llvm/test/Transforms/SLPVectorizer/X86/buildvectors-with-same-parents.ll
deleted file mode 100644
index daf9501f1b4ea..0000000000000
--- a/llvm/test/Transforms/SLPVectorizer/X86/buildvectors-with-same-parents.ll
+++ /dev/null
@@ -1,43 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s | FileCheck %s
-
-define i32 @test(i32 %0) {
-; CHECK-LABEL: define i32 @test(
-; CHECK-SAME: i32 [[TMP0:%.*]]) {
-; CHECK-NEXT: [[ENTRY:.*]]:
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32> <i32 0, i32 poison>, i32 [[TMP0]], i32 1
-; CHECK-NEXT: switch i32 0, label %[[BCI_130:.*]] [
-; CHECK-NEXT: i32 -4, label %[[BCI_96:.*]]
-; CHECK-NEXT: i32 3, label %[[BCI_130]]
-; CHECK-NEXT: i32 1, label %[[BCI_130]]
-; CHECK-NEXT: i32 9, label %[[BCI_108:.*]]
-; CHECK-NEXT: i32 0, label %[[BCI_130]]
-; CHECK-NEXT: ]
-; CHECK: [[BCI_130]]:
-; CHECK-NEXT: [[TMP2:%.*]] = phi <2 x i32> [ zeroinitializer, %[[BCI_108]] ], [ [[TMP1]], %[[BCI_96]] ], [ [[TMP1]], %[[ENTRY]] ], [ [[TMP1]], %[[ENTRY]] ], [ [[TMP1]], %[[ENTRY]] ], [ [[TMP1]], %[[ENTRY]] ]
-; CHECK-NEXT: ret i32 0
-; CHECK: [[BCI_108]]:
-; CHECK-NEXT: br label %[[BCI_130]]
-; CHECK: [[BCI_96]]:
-; CHECK-NEXT: br label %[[BCI_130]]
-;
-entry:
- switch i32 0, label %bci_130 [
- i32 -4, label %bci_96
- i32 3, label %bci_130
- i32 1, label %bci_130
- i32 9, label %bci_108
- i32 0, label %bci_130
- ]
-
-bci_130:
- %1 = phi i32 [ 0, %bci_108 ], [ %0, %bci_96 ], [ %0, %entry ], [ %0, %entry ], [ %0, %entry ], [ %0, %entry ]
- %local_2_10 = phi i32 [ 0, %bci_108 ], [ 0, %bci_96 ], [ 0, %entry ], [ 0, %entry ], [ 0, %entry ], [ 0, %entry ]
- ret i32 0
-
-bci_108:
- br label %bci_130
-
-bci_96:
- br label %bci_130
-}
More information about the llvm-commits
mailing list