[polly] r244443 - [Polly] Refactor buildScop

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 06:01:57 PDT 2015


Author: meinersbur
Date: Mon Aug 10 08:01:57 2015
New Revision: 244443

URL: http://llvm.org/viewvc/llvm-project?rev=244443&view=rev
Log:
[Polly] Refactor buildScop

Summary: The extracted function buildBBScopStmt will be needed later to be invoked individually on the region's exit block.

Reviewers: grosser, jdoerfert

Subscribers: jdoerfert, llvm-commits, pollydev

Projects: #polly

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

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=244443&r1=244442&r2=244443&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon Aug 10 08:01:57 2015
@@ -888,6 +888,20 @@ private:
                         const Region &CurRegion,
                         SmallVectorImpl<Loop *> &NestLoops);
 
+  /// @brief Create the ScopStmt for a BasicBlock and return its schedule.
+  ///
+  /// Returns null if the BB is trivial and no stmt has been created.
+  ///
+  /// @param BB         The basic block we build the statement for.
+  /// @param tempScop   The temp SCoP we use as model.
+  /// @param CurRegion  The SCoP region.
+  /// @param NestLoops  A vector of all surrounding loops.
+  ///
+  /// @return The ScopStmt's schedule.
+  __isl_give isl_schedule *buildBBScopStmt(BasicBlock *BB, TempScop &tempScop,
+                                           const Region &CurRegion,
+                                           SmallVectorImpl<Loop *> &NestLoops);
+
   /// @brief Build Scop and ScopStmts from a given TempScop.
   ///
   /// @param TempScop  The temporary scop that is translated into an actual

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=244443&r1=244442&r2=244443&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Aug 10 08:01:57 2015
@@ -76,6 +76,20 @@ static cl::opt<unsigned> RunTimeChecksMa
     cl::desc("The maximal number of arrays to compare in each alias group."),
     cl::Hidden, cl::ZeroOrMore, cl::init(20), cl::cat(PollyCategory));
 
+// Create a sequence of two schedules. Either argument may be null and is
+// interpreted as the empty schedule. Can also return null if both schedules are
+// empty.
+static __isl_give isl_schedule *
+combineInSequence(__isl_take isl_schedule *Prev,
+                  __isl_take isl_schedule *Succ) {
+  if (!Prev)
+    return Succ;
+  if (!Succ)
+    return Prev;
+
+  return isl_schedule_sequence(Prev, Succ);
+}
+
 /// Translate a 'const SCEV *' expression in an isl_pw_aff.
 struct SCEVAffinator : public SCEVVisitor<SCEVAffinator, isl_pw_aff *> {
 public:
@@ -2088,6 +2102,18 @@ ScopStmt *Scop::addScopStmt(BasicBlock *
   return Stmt;
 }
 
+__isl_give isl_schedule *
+Scop::buildBBScopStmt(BasicBlock *BB, TempScop &tempScop,
+                      const Region &CurRegion,
+                      SmallVectorImpl<Loop *> &NestLoops) {
+  if (isTrivialBB(BB, tempScop))
+    return nullptr;
+
+  auto *Stmt = addScopStmt(BB, nullptr, tempScop, CurRegion, NestLoops);
+  auto *Domain = Stmt->getDomain();
+  return isl_schedule_from_domain(isl_union_set_from_set(Domain));
+}
+
 __isl_give isl_schedule *Scop::buildScop(TempScop &tempScop,
                                          const Region &CurRegion,
                                          SmallVectorImpl<Loop *> &NestLoops,
@@ -2115,21 +2141,10 @@ __isl_give isl_schedule *Scop::buildScop
       StmtSchedule =
           buildScop(tempScop, *I->getNodeAs<Region>(), NestLoops, LI, SD);
     } else {
-      BasicBlock *BB = I->getNodeAs<BasicBlock>();
-
-      if (isTrivialBB(BB, tempScop)) {
-        continue;
-      } else {
-        auto *Stmt = addScopStmt(BB, nullptr, tempScop, CurRegion, NestLoops);
-        auto *Domain = Stmt->getDomain();
-        StmtSchedule = isl_schedule_from_domain(isl_union_set_from_set(Domain));
-      }
+      StmtSchedule = buildBBScopStmt(I->getNodeAs<BasicBlock>(), tempScop,
+                                     CurRegion, NestLoops);
     }
-
-    if (!Schedule)
-      Schedule = StmtSchedule;
-    else if (StmtSchedule)
-      Schedule = isl_schedule_sequence(Schedule, StmtSchedule);
+    Schedule = combineInSequence(Schedule, StmtSchedule);
   }
 
   if (!L)




More information about the llvm-commits mailing list