[polly] r221026 - Remove the MaxLoopDepth attribute from the TempScop class
Johannes Doerfert
doerfert at cs.uni-saarland.de
Fri Oct 31 17:12:13 PDT 2014
Author: jdoerfert
Date: Fri Oct 31 19:12:13 2014
New Revision: 221026
URL: http://llvm.org/viewvc/llvm-project?rev=221026&view=rev
Log:
Remove the MaxLoopDepth attribute from the TempScop class
Now MaxLoopDepth only lives in Scops not in TempScops anymore.
This is the first part of a series of changes to make TempScops
obsolete.
Differential Revision: http://reviews.llvm.org/D6069
Modified:
polly/trunk/include/polly/TempScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Analysis/TempScopInfo.cpp
Modified: polly/trunk/include/polly/TempScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/TempScopInfo.h?rev=221026&r1=221025&r2=221026&view=diff
==============================================================================
--- polly/trunk/include/polly/TempScopInfo.h (original)
+++ polly/trunk/include/polly/TempScopInfo.h Fri Oct 31 19:12:13 2014
@@ -127,9 +127,6 @@ class TempScop {
// The Region.
Region &R;
- // The max loop depth of this Scop
- unsigned MaxLoopDepth;
-
// Remember the bounds of loops, to help us build iteration domain of BBs.
const LoopBoundMapType &LoopBounds;
const BBCondMapType &BBConds;
@@ -141,8 +138,7 @@ class TempScop {
explicit TempScop(Region &r, LoopBoundMapType &loopBounds,
BBCondMapType &BBCmps, AccFuncMapType &accFuncMap)
- : R(r), MaxLoopDepth(0), LoopBounds(loopBounds), BBConds(BBCmps),
- AccFuncMap(accFuncMap) {}
+ : R(r), LoopBounds(loopBounds), BBConds(BBCmps), AccFuncMap(accFuncMap) {}
public:
~TempScop();
@@ -152,11 +148,6 @@ public:
/// @return The maximum Region contained by this Scop.
Region &getMaxRegion() const { return R; }
- /// @brief Get the maximum loop depth of Region R.
- ///
- /// @return The maximum loop depth of Region R.
- unsigned getMaxLoopDepth() const { return MaxLoopDepth; }
-
/// @brief Get the loop bounds of the given loop.
///
/// @param L The loop to get the bounds.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=221026&r1=221025&r2=221026&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Oct 31 19:12:13 2014
@@ -1416,10 +1416,30 @@ bool Scop::buildAliasGroups(AliasAnalysi
return Valid;
}
+static unsigned getMaxLoopDepthInRegion(const Region &R, LoopInfo &LI) {
+ unsigned MinLD = INT_MAX, MaxLD = 0;
+ for (BasicBlock *BB : R.blocks()) {
+ if (Loop *L = LI.getLoopFor(BB)) {
+ unsigned LD = L->getLoopDepth();
+ MinLD = std::min(MinLD, LD);
+ MaxLD = std::max(MaxLD, LD);
+ }
+ }
+
+ // Handle the case that there is no loop in the SCoP first.
+ if (MaxLD == 0)
+ return 1;
+
+ assert(MinLD >= 1 && "Minimal loop depth should be at least one");
+ assert(MaxLD >= MinLD &&
+ "Maximal loop depth was smaller than mininaml loop depth?");
+ return MaxLD - MinLD + 1;
+}
+
Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
isl_ctx *Context)
: SE(&ScalarEvolution), R(tempScop.getMaxRegion()),
- MaxLoopDepth(tempScop.getMaxLoopDepth()) {
+ MaxLoopDepth(getMaxLoopDepthInRegion(tempScop.getMaxRegion(), LI)) {
IslCtx = Context;
buildContext();
@@ -1785,7 +1805,7 @@ bool ScopInfo::runOnRegion(Region *R, RG
// Statistics.
++ScopFound;
- if (tempScop->getMaxLoopDepth() > 0)
+ if (scop->getMaxLoopDepth() > 0)
++RichScopFound;
scop = new Scop(*tempScop, LI, SE, ctx);
Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=221026&r1=221025&r2=221026&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Fri Oct 31 19:12:13 2014
@@ -73,8 +73,7 @@ inline raw_ostream &operator<<(raw_ostre
TempScop::~TempScop() {}
void TempScop::print(raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI) const {
- OS << "Scop: " << R.getNameStr() << ", Max Loop Depth: " << MaxLoopDepth
- << "\n";
+ OS << "Scop: " << R.getNameStr() << "\n";
printDetail(OS, SE, LI, &R, 0);
}
@@ -216,7 +215,6 @@ void TempScopInfo::buildAccessFunctions(
void TempScopInfo::buildLoopBounds(TempScop &Scop) {
Region &R = Scop.getMaxRegion();
- unsigned MaxLoopDepth = 0;
for (auto const &BB : R.blocks()) {
Loop *L = LI->getLoopFor(BB);
@@ -229,15 +227,7 @@ void TempScopInfo::buildLoopBounds(TempS
const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
LoopBounds[L] = BackedgeTakenCount;
-
- Loop *OL = R.outermostLoopInRegion(L);
- unsigned LoopDepth = L->getLoopDepth() - OL->getLoopDepth() + 1;
-
- if (LoopDepth > MaxLoopDepth)
- MaxLoopDepth = LoopDepth;
}
-
- Scop.MaxLoopDepth = MaxLoopDepth;
}
void TempScopInfo::buildAffineCondition(Value &V, bool inverted,
More information about the llvm-commits
mailing list