Skip to content

Commit 3320956

Browse files
committed
fixup! Collect loop guards only once per predecessor
1 parent 772fc50 commit 3320956

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15238,8 +15238,8 @@ void ScalarEvolution::LoopGuards::collectFromPHI(
1523815238
return;
1523915239

1524015240
using MinMaxPattern = std::pair<const SCEVConstant *, SCEVTypes>;
15241-
auto GetMinMaxConst = [&](unsigned In) -> MinMaxPattern {
15242-
const BasicBlock *InBlock = Phi.getIncomingBlock(In);
15241+
auto GetMinMaxConst = [&](unsigned IncomingIdx) -> MinMaxPattern {
15242+
const BasicBlock *InBlock = Phi.getIncomingBlock(IncomingIdx);
1524315243
if (!VisitedBlocks.insert(InBlock).second)
1524415244
return {nullptr, scCouldNotCompute};
1524515245
if (!IncomingGuards.contains(InBlock)) {
@@ -15249,7 +15249,7 @@ void ScalarEvolution::LoopGuards::collectFromPHI(
1524915249
IncomingGuards.try_emplace(InBlock, std::move(G));
1525015250
}
1525115251
const LoopGuards &G = IncomingGuards.at(InBlock);
15252-
auto S = G.RewriteMap.find(SE.getSCEV(Phi.getIncomingValue(In)));
15252+
auto S = G.RewriteMap.find(SE.getSCEV(Phi.getIncomingValue(IncomingIdx)));
1525315253
if (S == G.RewriteMap.end())
1525415254
return {nullptr, scCouldNotCompute};
1525515255
auto *SM = dyn_cast_if_present<SCEVMinMaxExpr>(S->second);
@@ -15687,9 +15687,8 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
1568715687
if (Pair.second->hasNPredecessorsOrMore(2) &&
1568815688
Depth < MaxLoopGuardCollectionDepth) {
1568915689
SmallDenseMap<const BasicBlock *, LoopGuards> IncomingGuards;
15690-
for (auto &Phi : Pair.second->phis()) {
15690+
for (auto &Phi : Pair.second->phis())
1569115691
collectFromPHI(SE, Guards, Phi, VisitedBlocks, IncomingGuards, Depth);
15692-
}
1569315692
}
1569415693

1569515694
// Now apply the information from the collected conditions to

0 commit comments

Comments
 (0)