[polly] r270424 - Add and use Scop::contains(Loop/BasicBlock/Instruction) [NFC]

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 05:40:49 PDT 2016


Author: jdoerfert
Date: Mon May 23 07:40:48 2016
New Revision: 270424

URL: http://llvm.org/viewvc/llvm-project?rev=270424&view=rev
Log:
Add and use Scop::contains(Loop/BasicBlock/Instruction) [NFC]

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/lib/Support/SCEVAffinator.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=270424&r1=270423&r2=270424&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon May 23 07:40:48 2016
@@ -1873,6 +1873,15 @@ public:
   /// @brief Return the function this SCoP is in.
   Function &getFunction() const { return *R.getEntry()->getParent(); }
 
+  /// @brief Check if @p L is contained in the SCoP.
+  bool contains(const Loop *L) const { return R.contains(L); }
+
+  /// @brief Check if @p BB is contained in the SCoP.
+  bool contains(const BasicBlock *BB) const { return R.contains(BB); }
+
+  /// @brief Check if @p I is contained in the SCoP.
+  bool contains(const Instruction *I) const { return R.contains(I); }
+
   /// @brief Get the maximum depth of the loop.
   ///
   /// @return The maximum depth of the loop.

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=270424&r1=270423&r2=270424&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon May 23 07:40:48 2016
@@ -155,7 +155,7 @@ static const ScopArrayInfo *identifyBase
   if (!BasePtrLI)
     return nullptr;
 
-  if (!S->getRegion().contains(BasePtrLI))
+  if (!S->contains(BasePtrLI))
     return nullptr;
 
   ScalarEvolution &SE = *S->getSE();
@@ -1882,8 +1882,8 @@ void Scop::addUserAssumptions(Assumption
     if (!CI || CI->getNumArgOperands() != 1)
       continue;
 
-    bool InR = R.contains(CI);
-    if (!InR && !DT.dominates(CI->getParent(), R.getEntry()))
+    bool InScop = contains(CI);
+    if (!InScop && !DT.dominates(CI->getParent(), R.getEntry()))
       continue;
 
     auto *L = LI.getLoopFor(CI->getParent());
@@ -1907,9 +1907,9 @@ void Scop::addUserAssumptions(Assumption
     }
 
     SmallVector<isl_set *, 2> ConditionSets;
-    auto *TI = InR ? CI->getParent()->getTerminator() : nullptr;
-    auto &Stmt = InR ? *getStmtFor(CI->getParent()) : *Stmts.begin();
-    auto *Dom = InR ? getDomainConditions(&Stmt) : isl_set_copy(Context);
+    auto *TI = InScop ? CI->getParent()->getTerminator() : nullptr;
+    auto &Stmt = InScop ? *getStmtFor(CI->getParent()) : *Stmts.begin();
+    auto *Dom = InScop ? getDomainConditions(&Stmt) : isl_set_copy(Context);
     bool Valid = buildConditionSets(Stmt, Val, TI, L, Dom, ConditionSets);
     isl_set_free(Dom);
 
@@ -1917,7 +1917,7 @@ void Scop::addUserAssumptions(Assumption
       continue;
 
     isl_set *AssumptionCtx = nullptr;
-    if (InR) {
+    if (InScop) {
       AssumptionCtx = isl_set_complement(isl_set_params(ConditionSets[1]));
       isl_set_free(ConditionSets[0]);
     } else {
@@ -2463,14 +2463,14 @@ void Scop::propagateDomainConstraintsToR
   auto *RI = R.getRegionInfo();
   auto *BBReg = RI ? RI->getRegionFor(BB) : nullptr;
   auto *ExitBB = BBReg ? BBReg->getExit() : nullptr;
-  if (!BBReg || BBReg->getEntry() != BB || !R.contains(ExitBB))
+  if (!BBReg || BBReg->getEntry() != BB || !contains(ExitBB))
     return;
 
   auto &BoxedLoops = getBoxedLoops();
   // Do not propagate the domain if there is a loop backedge inside the region
   // that would prevent the exit block from beeing executed.
   auto *L = BBLoop;
-  while (L && R.contains(L)) {
+  while (L && contains(L)) {
     SmallVector<BasicBlock *, 4> LatchBBs;
     BBLoop->getLoopLatches(LatchBBs);
     for (auto *LatchBB : LatchBBs)
@@ -2726,7 +2726,7 @@ bool Scop::propagateDomainConstraints(Re
     Domain = isl_set_align_params(Domain, getParamSpace());
 
     Loop *BBLoop = getRegionNodeLoop(RN, LI);
-    if (BBLoop && BBLoop->getHeader() == BB && getRegion().contains(BBLoop))
+    if (BBLoop && BBLoop->getHeader() == BB && contains(BBLoop))
       if (!addLoopBoundsToHeaderDomain(BBLoop, LI))
         return false;
   }
@@ -2866,7 +2866,7 @@ bool Scop::hasNonHoistableBasePtrInScop(
   auto *PointerBase = dyn_cast<SCEVUnknown>(SE->getPointerBase(BaseAddr));
   if (auto *BasePtrInst = dyn_cast<Instruction>(PointerBase->getValue()))
     if (!isa<LoadInst>(BasePtrInst))
-      return R.contains(BasePtrInst);
+      return contains(BasePtrInst);
 
   return false;
 }
@@ -3505,7 +3505,7 @@ __isl_give isl_set *Scop::getNonHoistabl
 void Scop::verifyInvariantLoads() {
   auto &RIL = getRequiredInvariantLoads();
   for (LoadInst *LI : RIL) {
-    assert(LI && getRegion().contains(LI));
+    assert(LI && contains(LI));
     ScopStmt *Stmt = getStmtFor(LI);
     if (Stmt && Stmt->getArrayAccessOrNULLFor(LI)) {
       invalidate(INVARIANTLOAD, LI->getDebugLoc());
@@ -4145,7 +4145,7 @@ void Scop::buildSchedule(Region *R, Loop
     }
 
     Loop *L = getRegionNodeLoop(RN, LI);
-    if (!getRegion().contains(L))
+    if (!contains(L))
       L = OuterScopLoop;
 
     Loop *LastLoop = LoopStack.back().L;
@@ -4302,7 +4302,7 @@ void ScopInfo::buildEscapingDependences(
     // scop's exit block. This is because region simplification before code
     // generation inserts new basic blocks before the PHI such that its incoming
     // blocks are not in the scop anymore.
-    if (!R->contains(UseParent) ||
+    if (!scop->contains(UseParent) ||
         (isa<PHINode>(UI) && UserParent == R->getExit() &&
          R->getExitingBlock())) {
       // At least one escaping use found.

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=270424&r1=270423&r2=270424&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Mon May 23 07:40:48 2016
@@ -127,7 +127,7 @@ Value *BlockGenerator::getNewValue(ScopS
 
   // A scop-constant value defined by an instruction executed outside the scop.
   if (const Instruction *Inst = dyn_cast<Instruction>(Old))
-    if (!Stmt.getParent()->getRegion().contains(Inst->getParent()))
+    if (!Stmt.getParent()->contains(Inst->getParent()))
       return Old;
 
   // The scalar dependence is neither available nor SCEVCodegenable.
@@ -369,7 +369,6 @@ void BlockGenerator::handleOutsideUsers(
   if (EscapeMap.count(Inst))
     return;
 
-  const auto &R = S.getRegion();
   EscapeUserVectorTy EscapeUsers;
   for (User *U : Inst->users()) {
 
@@ -378,7 +377,7 @@ void BlockGenerator::handleOutsideUsers(
     if (!UI)
       continue;
 
-    if (R.contains(UI))
+    if (S.contains(UI))
       continue;
 
     EscapeUsers.push_back(UI);
@@ -477,7 +476,7 @@ void BlockGenerator::createScalarInitial
       auto PHI = cast<PHINode>(Array->getBasePtr());
 
       for (auto BI = PHI->block_begin(), BE = PHI->block_end(); BI != BE; BI++)
-        if (!R.contains(*BI) && *BI != SplitBB)
+        if (!S.contains(*BI) && *BI != SplitBB)
           llvm_unreachable("Incoming edges from outside the scop should always "
                            "come from SplitBB");
 
@@ -493,7 +492,7 @@ void BlockGenerator::createScalarInitial
 
     auto *Inst = dyn_cast<Instruction>(Array->getBasePtr());
 
-    if (Inst && R.contains(Inst))
+    if (Inst && S.contains(Inst))
       continue;
 
     // PHI nodes that are not marked as such in their SAI object are either exit
@@ -556,7 +555,6 @@ void BlockGenerator::createScalarFinaliz
 }
 
 void BlockGenerator::findOutsideUsers(Scop &S) {
-  auto &R = S.getRegion();
   for (auto &Pair : S.arrays()) {
     auto &Array = Pair.second;
 
@@ -574,7 +572,7 @@ void BlockGenerator::findOutsideUsers(Sc
     // Scop invariant hoisting moves some of the base pointers out of the scop.
     // We can ignore these, as the invariant load hoisting already registers the
     // relevant outside users.
-    if (!R.contains(Inst))
+    if (!S.contains(Inst))
       continue;
 
     handleOutsideUsers(S, Inst);

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=270424&r1=270423&r2=270424&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Mon May 23 07:40:48 2016
@@ -229,7 +229,7 @@ static isl_stat addReferencesFromStmt(co
     if (Access->isArrayKind()) {
       auto *BasePtr = Access->getScopArrayInfo()->getBasePtr();
       if (Instruction *OpInst = dyn_cast<Instruction>(BasePtr))
-        if (Stmt->getParent()->getRegion().contains(OpInst))
+        if (Stmt->getParent()->contains(OpInst))
           continue;
 
       References.Values.insert(BasePtr);
@@ -314,7 +314,7 @@ void IslNodeBuilder::getReferencesInSubt
   /// are considered local. This leaves only loops that are before the scop, but
   /// do not contain the scop itself.
   Loops.remove_if([this](const Loop *L) {
-    return S.getRegion().contains(L) || L->contains(S.getRegion().getEntry());
+    return S.contains(L) || L->contains(S.getRegion().getEntry());
   });
 }
 
@@ -861,7 +861,7 @@ bool IslNodeBuilder::materializeValue(is
       // Check if the value is an instruction in a dead block within the SCoP
       // and if so do not code generate it.
       if (auto *Inst = dyn_cast<Instruction>(Val)) {
-        if (S.getRegion().contains(Inst)) {
+        if (S.contains(Inst)) {
           bool IsDead = true;
 
           // Check for "undef" loads first, then if there is a statement for
@@ -1147,7 +1147,6 @@ bool IslNodeBuilder::preloadInvariantEqu
     }
   }
 
-  const Region &R = S.getRegion();
   for (const MemoryAccess *MA : MAs) {
 
     Instruction *MAAccInst = MA->getAccessInstruction();
@@ -1155,7 +1154,7 @@ bool IslNodeBuilder::preloadInvariantEqu
     BlockGenerator::EscapeUserVectorTy EscapeUsers;
     for (auto *U : MAAccInst->users())
       if (Instruction *UI = dyn_cast<Instruction>(U))
-        if (!R.contains(UI))
+        if (!S.contains(UI))
           EscapeUsers.push_back(UI);
 
     if (EscapeUsers.empty())
@@ -1200,7 +1199,7 @@ void IslNodeBuilder::addParameters(__isl
   Region &R = S.getRegion();
   Loop *L = LI.getLoopFor(R.getEntry());
 
-  while (L != nullptr && R.contains(L))
+  while (L != nullptr && S.contains(L))
     L = L->getParentLoop();
 
   while (L != nullptr) {

Modified: polly/trunk/lib/Support/SCEVAffinator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVAffinator.cpp?rev=270424&r1=270423&r2=270424&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVAffinator.cpp (original)
+++ polly/trunk/lib/Support/SCEVAffinator.cpp Mon May 23 07:40:48 2016
@@ -437,7 +437,7 @@ __isl_give PWACtx SCEVAffinator::visitAd
 
   // Directly generate isl_pw_aff for Expr if 'start' is zero.
   if (Expr->getStart()->isZero()) {
-    assert(S->getRegion().contains(Expr->getLoop()) &&
+    assert(S->contains(Expr->getLoop()) &&
            "Scop does not contain the loop referenced in this AddRec");
 
     PWACtx Step = visit(Expr->getOperand(1));




More information about the llvm-commits mailing list