[PATCH] D43504: [SCEV] Factor out getLoopUseLists
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 01:30:45 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326072: [SCEV] Factor out getUsedLoops (authored by skatkov, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43504?vs=135024&id=135869#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43504
Files:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Index: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
@@ -1769,6 +1769,11 @@
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);
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -11341,9 +11341,13 @@
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 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43504.135869.patch
Type: text/x-patch
Size: 2034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180226/264a0744/attachment.bin>
More information about the llvm-commits
mailing list