Skip to content

Commit e3d5b2d

Browse files
committed
!fixup Undo SCEV changes, change SCEV invalidation order in LV.
1 parent 4603834 commit e3d5b2d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8441,7 +8441,7 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
84418441
// recusive call to getBackedgeTakenInfo (on a different
84428442
// loop), which would invalidate the iterator computed
84438443
// earlier.
8444-
return BackedgeTakenCounts[L] = std::move(Result);
8444+
return BackedgeTakenCounts.find(L)->second = std::move(Result);
84458445
}
84468446

84478447
void ScalarEvolution::forgetAllLoops() {
@@ -9866,10 +9866,8 @@ const SCEV *ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
98669866
for (auto &LS : reverse(ValuesAtScopes[V]))
98679867
if (LS.first == L) {
98689868
LS.second = C;
9869-
if (!isa<SCEVConstant>(C)) {
9869+
if (!isa<SCEVConstant>(C))
98709870
ValuesAtScopesUsers[C].push_back({L, V});
9871-
SCEVUsers[V].insert(C);
9872-
}
98739871
break;
98749872
}
98759873
return C;
@@ -14202,8 +14200,7 @@ void ScalarEvolution::forgetBackedgeTakenCounts(const Loop *L,
1420214200
for (const SCEV *S : {ENT.ExactNotTaken, ENT.SymbolicMaxNotTaken}) {
1420314201
if (!isa<SCEVConstant>(S)) {
1420414202
auto UserIt = BECountUsers.find(S);
14205-
if (UserIt == BECountUsers.end())
14206-
continue;
14203+
assert(UserIt != BECountUsers.end());
1420714204
UserIt->second.erase({L, Predicated});
1420814205
}
1420914206
}

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,10 +2928,6 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
29282928
if (EnableVPlanNativePath)
29292929
fixNonInductionPHIs(State);
29302930

2931-
// Forget the original basic block.
2932-
PSE.getSE()->forgetLoop(OrigLoop);
2933-
PSE.getSE()->forgetBlockAndLoopDispositions();
2934-
29352931
// After vectorization, the exit blocks of the original loop will have
29362932
// additional predecessors. Invalidate SCEVs for the exit phis in case SE
29372933
// looked through single-entry phis.
@@ -2941,6 +2937,10 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
29412937
for (PHINode &PN : Exit->phis())
29422938
PSE.getSE()->forgetLcssaPhiWithNewPredecessor(OrigLoop, &PN);
29432939

2940+
// Forget the original basic block.
2941+
PSE.getSE()->forgetLoop(OrigLoop);
2942+
PSE.getSE()->forgetBlockAndLoopDispositions();
2943+
29442944
// Don't apply optimizations below when no vector region remains, as they all
29452945
// require a vector loop at the moment.
29462946
if (!State.Plan->getVectorLoopRegion())

0 commit comments

Comments
 (0)