Skip to content

Commit 31845cf

Browse files
committed
Revert "[SLP]Fix non-determinism in reused elements analysis"
This reverts commit 3158525 to fix a bug revealed in https://lab.llvm.org/buildbot/#/builders/123/builds/14930
1 parent 93b0229 commit 31845cf

File tree

2 files changed

+9
-54
lines changed

2 files changed

+9
-54
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,7 +3801,7 @@ class BoUpSLP {
38013801
SetVector<const TreeEntry *> PostponedGathers;
38023802

38033803
using ValueToGatherNodesMap =
3804-
DenseMap<Value *, SmallSetVector<const TreeEntry *, 4>>;
3804+
DenseMap<Value *, SmallPtrSet<const TreeEntry *, 4>>;
38053805
ValueToGatherNodesMap ValueToGatherNodes;
38063806

38073807
/// A list of the load entries (node indices), which can be vectorized using
@@ -8328,15 +8328,14 @@ class PHIHandler {
83288328
}
83298329
return;
83308330
}
8331-
SmallMapVector<std::pair<BasicBlock *, unsigned>, SmallVector<unsigned>, 4>
8332-
Blocks;
8333-
for (unsigned I : seq<unsigned>(Main->getNumIncomingValues())) {
8331+
SmallDenseMap<BasicBlock *, SmallVector<unsigned>, 4> Blocks;
8332+
for (unsigned I : seq<unsigned>(0, Main->getNumIncomingValues())) {
83348333
BasicBlock *InBB = Main->getIncomingBlock(I);
83358334
if (!DT.isReachableFromEntry(InBB)) {
83368335
Operands[I].assign(Phis.size(), PoisonValue::get(Main->getType()));
83378336
continue;
83388337
}
8339-
Blocks.try_emplace(std::make_pair(InBB, I)).first->second.push_back(I);
8338+
Blocks.try_emplace(InBB).first->second.push_back(I);
83408339
}
83418340
for (auto [Idx, V] : enumerate(Phis)) {
83428341
if (isa<PoisonValue>(V)) {
@@ -8345,26 +8344,25 @@ class PHIHandler {
83458344
continue;
83468345
}
83478346
auto *P = cast<PHINode>(V);
8348-
for (unsigned I : seq<unsigned>(P->getNumIncomingValues())) {
8347+
for (unsigned I : seq<unsigned>(0, P->getNumIncomingValues())) {
83498348
BasicBlock *InBB = P->getIncomingBlock(I);
83508349
if (InBB == Main->getIncomingBlock(I)) {
83518350
if (isa_and_nonnull<PoisonValue>(Operands[I][Idx]))
83528351
continue;
83538352
Operands[I][Idx] = P->getIncomingValue(I);
83548353
continue;
83558354
}
8356-
auto *It = Blocks.find(std::make_pair(InBB, I));
8355+
auto It = Blocks.find(InBB);
83578356
if (It == Blocks.end())
83588357
continue;
83598358
Operands[It->second.front()][Idx] = P->getIncomingValue(I);
83608359
}
83618360
}
83628361
for (const auto &P : Blocks) {
8363-
ArrayRef<unsigned> IncomingValues = P.second;
8364-
if (IncomingValues.size() <= 1)
8362+
if (P.getSecond().size() <= 1)
83658363
continue;
8366-
unsigned BasicI = IncomingValues.front();
8367-
for (unsigned I : IncomingValues.drop_front()) {
8364+
unsigned BasicI = P.getSecond().front();
8365+
for (unsigned I : ArrayRef(P.getSecond()).drop_front()) {
83688366
assert(all_of(enumerate(Operands[I]),
83698367
[&](const auto &Data) {
83708368
return !Data.value() ||

llvm/test/Transforms/SLPVectorizer/X86/buildvectors-with-same-parents.ll

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)