[llvm] r326072 - [SCEV] Factor out getUsedLoops
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 01:26:41 PST 2018
Author: skatkov
Date: Mon Feb 26 01:26:41 2018
New Revision: 326072
URL: http://llvm.org/viewvc/llvm-project?rev=326072&view=rev
Log:
[SCEV] Factor out getUsedLoops
The patch introduces the new function in ScalarEvolution to get
all loops used in specified SCEV.
This is a preparation for re-writing isKnownPredicate utility as
described in https://reviews.llvm.org/D42417.
Reviewers: sanjoy, mkazantsev, reames
Reviewed By: sanjoy
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D43504
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=326072&r1=326071&r2=326072&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon Feb 26 01:26:41 2018
@@ -1769,6 +1769,11 @@ private:
const SCEV *getOrCreateMulExpr(SmallVectorImpl<const SCEV *> &Ops,
SCEV::NoWrapFlags Flags);
+ /// Find all of the loops transitively used in \p S, and fill \p LoopsUsed.
+ /// A loop is considered "used" by an expression if it contains
+ /// an add rec on said loop.
+ void getUsedLoops(const SCEV *S, SmallPtrSetImpl<const Loop *> &LoopsUsed);
+
/// Find all of the loops transitively used in \p S, and update \c LoopUsers
/// accordingly.
void addToLoopUseLists(const SCEV *S);
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=326072&r1=326071&r2=326072&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Feb 26 01:26:41 2018
@@ -11341,9 +11341,13 @@ ScalarEvolution::forgetMemoizedResults(c
RemoveSCEVFromBackedgeMap(PredicatedBackedgeTakenCounts);
}
-void ScalarEvolution::addToLoopUseLists(const SCEV *S) {
+void
+ScalarEvolution::getUsedLoops(const SCEV *S,
+ SmallPtrSetImpl<const Loop *> &LoopsUsed) {
struct FindUsedLoops {
- SmallPtrSet<const Loop *, 8> LoopsUsed;
+ FindUsedLoops(SmallPtrSetImpl<const Loop *> &LoopsUsed)
+ : LoopsUsed(LoopsUsed) {}
+ SmallPtrSetImpl<const Loop *> &LoopsUsed;
bool follow(const SCEV *S) {
if (auto *AR = dyn_cast<SCEVAddRecExpr>(S))
LoopsUsed.insert(AR->getLoop());
@@ -11353,10 +11357,14 @@ void ScalarEvolution::addToLoopUseLists(
bool isDone() const { return false; }
};
- FindUsedLoops F;
+ FindUsedLoops F(LoopsUsed);
SCEVTraversal<FindUsedLoops>(F).visitAll(S);
+}
- for (auto *L : F.LoopsUsed)
+void ScalarEvolution::addToLoopUseLists(const SCEV *S) {
+ SmallPtrSet<const Loop *, 8> LoopsUsed;
+ getUsedLoops(S, LoopsUsed);
+ for (auto *L : LoopsUsed)
LoopUsers[L].push_back(S);
}
More information about the llvm-commits
mailing list