Skip to content

Commit 36f5626

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

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15242,15 +15242,13 @@ void ScalarEvolution::LoopGuards::collectFromPHI(
1524215242
const BasicBlock *InBlock = Phi.getIncomingBlock(IncomingIdx);
1524315243
if (!VisitedBlocks.insert(InBlock).second)
1524415244
return {nullptr, scCouldNotCompute};
15245-
if (!IncomingGuards.contains(InBlock)) {
15246-
LoopGuards G(SE);
15247-
collectFromBlock(SE, G, Phi.getParent(), InBlock, VisitedBlocks,
15245+
auto [G, Inserted] = IncomingGuards.try_emplace(InBlock, LoopGuards(SE));
15246+
if (Inserted)
15247+
collectFromBlock(SE, G->second, Phi.getParent(), InBlock, VisitedBlocks,
1524815248
Depth + 1);
15249-
IncomingGuards.try_emplace(InBlock, std::move(G));
15250-
}
15251-
const LoopGuards &G = IncomingGuards.at(InBlock);
15252-
auto S = G.RewriteMap.find(SE.getSCEV(Phi.getIncomingValue(IncomingIdx)));
15253-
if (S == G.RewriteMap.end())
15249+
auto S = G->second.RewriteMap.find(
15250+
SE.getSCEV(Phi.getIncomingValue(IncomingIdx)));
15251+
if (S == G->second.RewriteMap.end())
1525415252
return {nullptr, scCouldNotCompute};
1525515253
auto *SM = dyn_cast_if_present<SCEVMinMaxExpr>(S->second);
1525615254
if (!SM)

0 commit comments

Comments
 (0)