Skip to content

Commit 00ff746

Browse files
committed
[LoopSimplify] Reduce amount of redundant SCEV invalidation (NFCI)
We are simplifying the loop and all its children. Each time, we invalidate the top-most loop. The top-most loop is going to be the same every time. The cost of SCEV invalidation is largely independent from how data about the loop is actually cached, so we should avoid redundant invalidations.
1 parent 29712cc commit 00ff746

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/Transforms/Utils/LoopSimplify.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,6 @@ static bool simplifyOneLoop(Loop *L, SmallVectorImpl<Loop *> &Worklist,
693693
}
694694
}
695695

696-
// Changing exit conditions for blocks may affect exit counts of this loop and
697-
// any of its paretns, so we must invalidate the entire subtree if we've made
698-
// any changes.
699-
if (Changed && SE)
700-
SE->forgetTopmostLoop(L);
701-
702696
if (MSSAU && VerifyMemorySSA)
703697
MSSAU->getMemorySSA()->verifyMemorySSA();
704698

@@ -737,6 +731,13 @@ bool llvm::simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI,
737731
Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, DT, LI, SE,
738732
AC, MSSAU, PreserveLCSSA);
739733

734+
// Changing exit conditions for blocks may affect exit counts of this loop and
735+
// any of its parents, so we must invalidate the entire subtree if we've made
736+
// any changes. Do this here rather than in simplifyOneLoop() as the top-most
737+
// loop is going to be the same for all child loops.
738+
if (Changed && SE)
739+
SE->forgetTopmostLoop(L);
740+
740741
return Changed;
741742
}
742743

0 commit comments

Comments
 (0)