Remove the LoopBounds from the TempScop class.
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>
Sat, 1 Nov 2014 01:14:56 +0000 (01:14 +0000)
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>
Sat, 1 Nov 2014 01:14:56 +0000 (01:14 +0000)
  We will use ScalarEvolution in the ScopInfo.cpp to get the loop trip
  count, not cache it in the TempScop object.

Differential Revision: http://reviews.llvm.org/D6070

llvm-svn: 221035

polly/include/polly/TempScopInfo.h
polly/lib/Analysis/ScopInfo.cpp
polly/lib/Analysis/TempScopInfo.cpp

index f43863c..cc23ccc 100644 (file)
@@ -128,7 +128,6 @@ class TempScop {
   Region &R;
 
   // Remember the bounds of loops, to help us build iteration domain of BBs.
-  const LoopBoundMapType &LoopBounds;
   const BBCondMapType &BBConds;
 
   // Access function of bbs.
@@ -136,9 +135,9 @@ class TempScop {
 
   friend class TempScopInfo;
 
-  explicit TempScop(Region &r, LoopBoundMapType &loopBounds,
-                    BBCondMapType &BBCmps, AccFuncMapType &accFuncMap)
-      : R(r), LoopBounds(loopBounds), BBConds(BBCmps), AccFuncMap(accFuncMap) {}
+  explicit TempScop(Region &r, BBCondMapType &BBCmps,
+                    AccFuncMapType &accFuncMap)
+      : R(r), BBConds(BBCmps), AccFuncMap(accFuncMap) {}
 
 public:
   ~TempScop();
@@ -148,18 +147,6 @@ public:
   /// @return The maximum Region contained by this Scop.
   Region &getMaxRegion() const { return R; }
 
-  /// @brief Get the loop bounds of the given loop.
-  ///
-  /// @param L The loop to get the bounds.
-  ///
-  /// @return The bounds of the loop L in { Lower bound, Upper bound } form.
-  ///
-  const SCEV *getLoopBound(const Loop *L) const {
-    LoopBoundMapType::const_iterator at = LoopBounds.find(L);
-    assert(at != LoopBounds.end() && "Bound for loop not available!");
-    return at->second;
-  }
-
   /// @brief Get the condition from entry block of the Scop to a BasicBlock
   ///
   /// @param BB The BasicBlock
@@ -229,9 +216,6 @@ class TempScopInfo : public FunctionPass {
   // Target data for element size computing.
   const DataLayout *TD;
 
-  // Remember the bounds of loops, to help us build iteration domain of BBs.
-  LoopBoundMapType LoopBounds;
-
   // And also Remember the constrains for BBs
   BBCondMapType BBConds;
 
@@ -288,8 +272,6 @@ class TempScopInfo : public FunctionPass {
 
   void buildAccessFunctions(Region &RefRegion, BasicBlock &BB);
 
-  void buildLoopBounds(TempScop &Scop);
-
 public:
   static char ID;
   explicit TempScopInfo() : FunctionPass(ID) {}
index 89696e2..3ce42a0 100644 (file)
@@ -788,6 +788,7 @@ __isl_give isl_set *ScopStmt::addLoopBoundsToDomain(__isl_take isl_set *Domain,
   Space = isl_set_get_space(Domain);
   LocalSpace = isl_local_space_from_space(Space);
 
+  ScalarEvolution *SE = getParent()->getSE();
   for (int i = 0, e = getNumIterators(); i != e; ++i) {
     isl_aff *Zero = isl_aff_zero_on_domain(isl_local_space_copy(LocalSpace));
     isl_pw_aff *IV =
@@ -799,7 +800,7 @@ __isl_give isl_set *ScopStmt::addLoopBoundsToDomain(__isl_take isl_set *Domain,
 
     // IV <= LatchExecutions.
     const Loop *L = getLoopForDimension(i);
-    const SCEV *LatchExecutions = tempScop.getLoopBound(L);
+    const SCEV *LatchExecutions = SE->getBackedgeTakenCount(L);
     isl_pw_aff *UpperBound = SCEVAffinator::getPwAff(this, LatchExecutions);
     isl_set *UpperBoundSet = isl_pw_aff_le_set(IV, UpperBound);
     Domain = isl_set_intersect(Domain, UpperBoundSet);
index 570389b..b7ab549 100644 (file)
@@ -213,23 +213,6 @@ void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB) {
   Accs.insert(Accs.end(), Functions.begin(), Functions.end());
 }
 
-void TempScopInfo::buildLoopBounds(TempScop &Scop) {
-  Region &R = Scop.getMaxRegion();
-
-  for (auto const &BB : R.blocks()) {
-    Loop *L = LI->getLoopFor(BB);
-
-    if (!L || !R.contains(L))
-      continue;
-
-    if (LoopBounds.find(L) != LoopBounds.end())
-      continue;
-
-    const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
-    LoopBounds[L] = BackedgeTakenCount;
-  }
-}
-
 void TempScopInfo::buildAffineCondition(Value &V, bool inverted,
                                         Comparison **Comp) const {
   if (ConstantInt *C = dyn_cast<ConstantInt>(&V)) {
@@ -312,15 +295,13 @@ void TempScopInfo::buildCondition(BasicBlock *BB, BasicBlock *RegionEntry) {
 }
 
 TempScop *TempScopInfo::buildTempScop(Region &R) {
-  TempScop *TScop = new TempScop(R, LoopBounds, BBConds, AccFuncMap);
+  TempScop *TScop = new TempScop(R, BBConds, AccFuncMap);
 
   for (const auto &BB : R.blocks()) {
     buildAccessFunctions(R, *BB);
     buildCondition(BB, R.getEntry());
   }
 
-  buildLoopBounds(*TScop);
-
   return TScop;
 }
 
@@ -372,7 +353,6 @@ TempScopInfo::~TempScopInfo() { clear(); }
 
 void TempScopInfo::clear() {
   BBConds.clear();
-  LoopBounds.clear();
   AccFuncMap.clear();
   DeleteContainerSeconds(TempScops);
   TempScops.clear();