[PATCH] D112294: [SCEV][NFC] Win some compile time from mass forgetMemoizedResults
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 22 00:20:39 PDT 2021
mkazantsev created this revision.
mkazantsev added reviewers: reames, lebedev.ri, nikic, efriedma.
Herald added subscribers: javed.absar, hiraditya.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Mass forgetMemoizedResults can be done more efficiently than bunch
of individual invocations of helper because we can traverse maps being
updated just once, rather than doing this for each invidivual SCEV.
Should be NFC and supposedly improves compile time.
https://reviews.llvm.org/D112294
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -12834,42 +12834,43 @@
void ScalarEvolution::forgetMemoizedResults(ArrayRef<const SCEV *> SCEVs) {
for (auto *S : SCEVs)
forgetMemoizedResultsImpl(S);
-}
-
-void ScalarEvolution::forgetMemoizedResultsImpl(const SCEV *S) {
- ValuesAtScopes.erase(S);
- LoopDispositions.erase(S);
- BlockDispositions.erase(S);
- UnsignedRanges.erase(S);
- SignedRanges.erase(S);
- ExprValueMap.erase(S);
- HasRecMap.erase(S);
- MinTrailingZerosCache.erase(S);
-
+ SmallPtrSet<const SCEV *, 8> ToForget(SCEVs.begin(), SCEVs.end());
for (auto I = PredicatedSCEVRewrites.begin();
I != PredicatedSCEVRewrites.end();) {
std::pair<const SCEV *, const Loop *> Entry = I->first;
- if (Entry.first == S)
+ if (ToForget.count(Entry.first))
PredicatedSCEVRewrites.erase(I++);
else
++I;
}
- auto RemoveSCEVFromBackedgeMap =
- [S](DenseMap<const Loop *, BackedgeTakenInfo> &Map) {
+ auto RemoveSCEVFromBackedgeMap = [this, &ToForget](
+ DenseMap<const Loop *, BackedgeTakenInfo> &Map) {
for (auto I = Map.begin(), E = Map.end(); I != E;) {
BackedgeTakenInfo &BEInfo = I->second;
- if (BEInfo.hasOperand(S))
+ if (any_of(ToForget,
+ [&BEInfo](const SCEV *S) { return BEInfo.hasOperand(S); }))
Map.erase(I++);
else
++I;
}
- };
+ };
RemoveSCEVFromBackedgeMap(BackedgeTakenCounts);
RemoveSCEVFromBackedgeMap(PredicatedBackedgeTakenCounts);
}
+void ScalarEvolution::forgetMemoizedResultsImpl(const SCEV *S) {
+ ValuesAtScopes.erase(S);
+ LoopDispositions.erase(S);
+ BlockDispositions.erase(S);
+ UnsignedRanges.erase(S);
+ SignedRanges.erase(S);
+ ExprValueMap.erase(S);
+ HasRecMap.erase(S);
+ MinTrailingZerosCache.erase(S);
+}
+
void
ScalarEvolution::getUsedLoops(const SCEV *S,
SmallPtrSetImpl<const Loop *> &LoopsUsed) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112294.381471.patch
Type: text/x-patch
Size: 2128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211022/b3372ccc/attachment.bin>
More information about the llvm-commits
mailing list