Skip to content

Commit dce73e1

Browse files
committed
Revert "[SLP]Fix PR107037: correctly track origonal/modified after vectorizations reduced values"
This reverts commit 98bb354 to fix buildbots https://lab.llvm.org/buildbot/#/builders/155/builds/2056 and https://lab.llvm.org/buildbot/#/builders/11/builds/4407
1 parent 3209766 commit dce73e1

File tree

2 files changed

+14
-66
lines changed

2 files changed

+14
-66
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17778,12 +17778,10 @@ class HorizontalReduction {
1777817778
// Emit code for constant values.
1777917779
if (Candidates.size() > 1 && allConstant(Candidates)) {
1778017780
Value *Res = Candidates.front();
17781-
Value *OrigV = TrackedToOrig.find(Candidates.front())->second;
17782-
++VectorizedVals.try_emplace(OrigV).first->getSecond();
17781+
++VectorizedVals.try_emplace(Candidates.front(), 0).first->getSecond();
1778317782
for (Value *VC : ArrayRef(Candidates).drop_front()) {
1778417783
Res = createOp(Builder, RdxKind, Res, VC, "const.rdx", ReductionOps);
17785-
Value *OrigV = TrackedToOrig.find(VC)->second;
17786-
++VectorizedVals.try_emplace(OrigV).first->getSecond();
17784+
++VectorizedVals.try_emplace(VC, 0).first->getSecond();
1778717785
if (auto *ResI = dyn_cast<Instruction>(Res))
1778817786
V.analyzedReductionRoot(ResI);
1778917787
}
@@ -17804,10 +17802,8 @@ class HorizontalReduction {
1780417802
// Gather same values.
1780517803
MapVector<Value *, unsigned> SameValuesCounter;
1780617804
if (IsSupportedHorRdxIdentityOp)
17807-
for (Value *V : Candidates) {
17808-
Value *OrigV = TrackedToOrig.find(V)->second;
17809-
++SameValuesCounter.try_emplace(OrigV).first->second;
17810-
}
17805+
for (Value *V : Candidates)
17806+
++SameValuesCounter.insert(std::make_pair(V, 0)).first->second;
1781117807
// Used to check if the reduced values used same number of times. In this
1781217808
// case the compiler may produce better code. E.g. if reduced values are
1781317809
// aabbccdd (8 x values), then the first node of the tree will have a node
@@ -17831,12 +17827,12 @@ class HorizontalReduction {
1783117827
});
1783217828
Candidates.resize(SameValuesCounter.size());
1783317829
transform(SameValuesCounter, Candidates.begin(),
17834-
[&](const auto &P) { return TrackedVals.at(P.first); });
17830+
[](const auto &P) { return P.first; });
1783517831
NumReducedVals = Candidates.size();
1783617832
// Have a reduction of the same element.
1783717833
if (NumReducedVals == 1) {
1783817834
Value *OrigV = TrackedToOrig.find(Candidates.front())->second;
17839-
unsigned Cnt = SameValuesCounter.find(OrigV)->second;
17835+
unsigned Cnt = SameValuesCounter.lookup(OrigV);
1784017836
Value *RedVal =
1784117837
emitScaleForReusedOps(Candidates.front(), Builder, Cnt);
1784217838
VectorizedTree = GetNewVectorizedTree(VectorizedTree, RedVal);
@@ -17941,7 +17937,7 @@ class HorizontalReduction {
1794117937
continue;
1794217938
Value *V = Candidates[Cnt];
1794317939
Value *OrigV = TrackedToOrig.find(V)->second;
17944-
++SameValuesCounter.find(OrigV)->second;
17940+
++SameValuesCounter[OrigV];
1794517941
}
1794617942
}
1794717943
SmallPtrSet<Value *, 4> VLScalars(VL.begin(), VL.end());
@@ -17960,8 +17956,8 @@ class HorizontalReduction {
1796017956
continue;
1796117957
}
1796217958
Value *OrigV = TrackedToOrig.find(RdxVal)->second;
17963-
unsigned NumOps = VectorizedVals.lookup(OrigV) +
17964-
SameValuesCounter.find(OrigV)->second;
17959+
unsigned NumOps =
17960+
VectorizedVals.lookup(RdxVal) + SameValuesCounter[OrigV];
1796517961
if (NumOps != ReducedValsToOps.find(OrigV)->second.size())
1796617962
LocalExternallyUsedValues[RdxVal];
1796717963
}
@@ -18089,11 +18085,10 @@ class HorizontalReduction {
1808918085
for (Value *RdxVal : VL) {
1809018086
Value *OrigV = TrackedToOrig.find(RdxVal)->second;
1809118087
if (IsSupportedHorRdxIdentityOp) {
18092-
VectorizedVals.try_emplace(OrigV,
18093-
SameValuesCounter.find(OrigV)->second);
18088+
VectorizedVals.try_emplace(OrigV, SameValuesCounter[RdxVal]);
1809418089
continue;
1809518090
}
18096-
++VectorizedVals.try_emplace(OrigV).first->getSecond();
18091+
++VectorizedVals.try_emplace(OrigV, 0).first->getSecond();
1809718092
if (!V.isVectorized(RdxVal))
1809818093
RequiredExtract.insert(RdxVal);
1809918094
}
@@ -18104,10 +18099,10 @@ class HorizontalReduction {
1810418099
}
1810518100
if (OptReusedScalars && !AnyVectorized) {
1810618101
for (const std::pair<Value *, unsigned> &P : SameValuesCounter) {
18107-
Value *RdxVal = TrackedVals.find(P.first)->second;
18108-
Value *RedVal = emitScaleForReusedOps(RdxVal, Builder, P.second);
18102+
Value *RedVal = emitScaleForReusedOps(P.first, Builder, P.second);
1810918103
VectorizedTree = GetNewVectorizedTree(VectorizedTree, RedVal);
18110-
VectorizedVals.try_emplace(P.first, P.second);
18104+
Value *OrigV = TrackedToOrig.find(P.first)->second;
18105+
VectorizedVals.try_emplace(OrigV, P.second);
1811118106
}
1811218107
continue;
1811318108
}

llvm/test/Transforms/SLPVectorizer/X86/multi-tracked-reduced-value.ll

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

0 commit comments

Comments
 (0)