[polly] r289791 - Remove references to AssumptionCache. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 01:25:15 PST 2016


Author: meinersbur
Date: Thu Dec 15 03:25:14 2016
New Revision: 289791

URL: http://llvm.org/viewvc/llvm-project?rev=289791&view=rev
Log:
Remove references to AssumptionCache. NFC.

The AssumptionCache was removed in r289756 after being replaced by the an
addtional operand list of affected values in r289755. The absence of that cache
means that we have now have to manually search for llvm.assume intrinsics as
now done by other passes (LazyValueInfo, CodeMetrics) do not take into
account an llvm::Instruction's user lists (ScalarEvolution).

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

Modified: polly/trunk/include/polly/ScopBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopBuilder.h?rev=289791&r1=289790&r2=289791&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Thu Dec 15 03:25:14 2016
@@ -55,7 +55,7 @@ class ScopBuilder {
   std::unique_ptr<Scop> scop;
 
   // Build the SCoP for Region @p R.
-  void buildScop(Region &R, AssumptionCache &AC);
+  void buildScop(Region &R);
 
   /// Try to build a multi-dimensional fixed sized MemoryAccess from the
   /// Load/Store instruction.
@@ -242,9 +242,9 @@ class ScopBuilder {
   void addPHIReadAccess(PHINode *PHI);
 
 public:
-  explicit ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
-                       const DataLayout &DL, DominatorTree &DT, LoopInfo &LI,
-                       ScopDetection &SD, ScalarEvolution &SE);
+  explicit ScopBuilder(Region *R, AliasAnalysis &AA, const DataLayout &DL,
+                       DominatorTree &DT, LoopInfo &LI, ScopDetection &SD,
+                       ScalarEvolution &SE);
   ~ScopBuilder() {}
 
   /// Try to build the Polly IR of static control part on the current

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=289791&r1=289790&r2=289791&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Dec 15 03:25:14 2016
@@ -33,7 +33,6 @@
 using namespace llvm;
 
 namespace llvm {
-class AssumptionCache;
 class Loop;
 class LoopInfo;
 class PHINode;
@@ -1670,8 +1669,7 @@ private:
   //@}
 
   /// Initialize this ScopBuilder.
-  void init(AliasAnalysis &AA, AssumptionCache &AC, DominatorTree &DT,
-            LoopInfo &LI);
+  void init(AliasAnalysis &AA, DominatorTree &DT, LoopInfo &LI);
 
   /// Propagate domains that are known due to graph properties.
   ///
@@ -1845,7 +1843,7 @@ private:
   void buildContext();
 
   /// Add user provided parameter constraints to context (source code).
-  void addUserAssumptions(AssumptionCache &AC, DominatorTree &DT, LoopInfo &LI);
+  void addUserAssumptions(DominatorTree &DT, LoopInfo &LI);
 
   /// Add user provided parameter constraints to context (command line).
   void addUserContext();

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=289791&r1=289790&r2=289791&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Thu Dec 15 03:25:14 2016
@@ -645,7 +645,7 @@ void ScopBuilder::addPHIReadAccess(PHINo
                   ArrayRef<const SCEV *>(), ScopArrayInfo::MK_PHI);
 }
 
-void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
+void ScopBuilder::buildScop(Region &R) {
   scop.reset(new Scop(R, SE, LI, *SD.getDetectionContext(&R)));
 
   buildStmts(R);
@@ -669,12 +669,12 @@ void ScopBuilder::buildScop(Region &R, A
       addArrayAccess(MemAccInst(GlobalRead), MemoryAccess::READ, BP,
                      BP->getType(), false, {AF}, {nullptr}, GlobalRead);
 
-  scop->init(AA, AC, DT, LI);
+  scop->init(AA, DT, LI);
 }
 
-ScopBuilder::ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
-                         const DataLayout &DL, DominatorTree &DT, LoopInfo &LI,
-                         ScopDetection &SD, ScalarEvolution &SE)
+ScopBuilder::ScopBuilder(Region *R, AliasAnalysis &AA, const DataLayout &DL,
+                         DominatorTree &DT, LoopInfo &LI, ScopDetection &SD,
+                         ScalarEvolution &SE)
     : AA(AA), DL(DL), DT(DT), LI(LI), SD(SD), SE(SE) {
 
   Function *F = R->getEntry()->getParent();
@@ -684,7 +684,7 @@ ScopBuilder::ScopBuilder(Region *R, Assu
   std::string Msg = "SCoP begins here.";
   emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F, Beg, Msg);
 
-  buildScop(*R, AC);
+  buildScop(*R);
 
   DEBUG(scop->print(dbgs()));
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=289791&r1=289790&r2=289791&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Dec 15 03:25:14 2016
@@ -29,10 +29,10 @@
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/LoopIterator.h"
@@ -1849,76 +1849,82 @@ bool Scop::isDominatedBy(const Dominator
   return DT.dominates(BB, getEntry());
 }
 
-void Scop::addUserAssumptions(AssumptionCache &AC, DominatorTree &DT,
-                              LoopInfo &LI) {
+void Scop::addUserAssumptions(DominatorTree &DT, LoopInfo &LI) {
   auto &F = getFunction();
-  for (auto &Assumption : AC.assumptions()) {
-    auto *CI = dyn_cast_or_null<CallInst>(Assumption);
-    if (!CI || CI->getNumArgOperands() != 1)
-      continue;
 
-    bool InScop = contains(CI);
-    if (!InScop && !isDominatedBy(DT, CI->getParent()))
+  // TODO: Walk the DominatorTree from getRegion().getExit() to its root in
+  // order to not iterate over blocks we skip anyways.
+  for (auto &BB : F) {
+    bool InScop = contains(&BB);
+    if (!InScop && !isDominatedBy(DT, &BB))
       continue;
 
-    auto *L = LI.getLoopFor(CI->getParent());
-    auto *Val = CI->getArgOperand(0);
-    ParameterSetTy DetectedParams;
-    if (!isAffineConstraint(Val, &R, L, *SE, DetectedParams)) {
-      emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
-                                     CI->getDebugLoc(),
-                                     "Non-affine user assumption ignored.");
-      continue;
-    }
+    for (auto &Assumption : BB) {
+      auto *CI = dyn_cast_or_null<IntrinsicInst>(&Assumption);
+      if (!CI || CI->getNumArgOperands() != 1 ||
+          CI->getIntrinsicID() != Intrinsic::assume)
+        continue;
 
-    // Collect all newly introduced parameters.
-    ParameterSetTy NewParams;
-    for (auto *Param : DetectedParams) {
-      Param = extractConstantFactor(Param, *SE).second;
-      Param = getRepresentingInvariantLoadSCEV(Param);
-      if (Parameters.count(Param))
+      auto *L = LI.getLoopFor(CI->getParent());
+      auto *Val = CI->getArgOperand(0);
+      ParameterSetTy DetectedParams;
+      if (!isAffineConstraint(Val, &R, L, *SE, DetectedParams)) {
+        emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
+                                       CI->getDebugLoc(),
+                                       "Non-affine user assumption ignored.");
         continue;
-      NewParams.insert(Param);
-    }
+      }
 
-    SmallVector<isl_set *, 2> ConditionSets;
-    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);
+      // Collect all newly introduced parameters.
+      ParameterSetTy NewParams;
+      for (auto *Param : DetectedParams) {
+        Param = extractConstantFactor(Param, *SE).second;
+        Param = getRepresentingInvariantLoadSCEV(Param);
+        if (Parameters.count(Param))
+          continue;
+        NewParams.insert(Param);
+      }
 
-    if (!Valid)
-      continue;
+      SmallVector<isl_set *, 2> ConditionSets;
+      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);
 
-    isl_set *AssumptionCtx = nullptr;
-    if (InScop) {
-      AssumptionCtx = isl_set_complement(isl_set_params(ConditionSets[1]));
-      isl_set_free(ConditionSets[0]);
-    } else {
-      AssumptionCtx = isl_set_complement(ConditionSets[1]);
-      AssumptionCtx = isl_set_intersect(AssumptionCtx, ConditionSets[0]);
-    }
+      if (!Valid)
+        continue;
 
-    // Project out newly introduced parameters as they are not otherwise useful.
-    if (!NewParams.empty()) {
-      for (unsigned u = 0; u < isl_set_n_param(AssumptionCtx); u++) {
-        auto *Id = isl_set_get_dim_id(AssumptionCtx, isl_dim_param, u);
-        auto *Param = static_cast<const SCEV *>(isl_id_get_user(Id));
-        isl_id_free(Id);
+      isl_set *AssumptionCtx = nullptr;
+      if (InScop) {
+        AssumptionCtx = isl_set_complement(isl_set_params(ConditionSets[1]));
+        isl_set_free(ConditionSets[0]);
+      } else {
+        AssumptionCtx = isl_set_complement(ConditionSets[1]);
+        AssumptionCtx = isl_set_intersect(AssumptionCtx, ConditionSets[0]);
+      }
 
-        if (!NewParams.count(Param))
-          continue;
+      // Project out newly introduced parameters as they are not otherwise
+      // useful.
+      if (!NewParams.empty()) {
+        for (unsigned u = 0; u < isl_set_n_param(AssumptionCtx); u++) {
+          auto *Id = isl_set_get_dim_id(AssumptionCtx, isl_dim_param, u);
+          auto *Param = static_cast<const SCEV *>(isl_id_get_user(Id));
+          isl_id_free(Id);
 
-        AssumptionCtx =
-            isl_set_project_out(AssumptionCtx, isl_dim_param, u--, 1);
+          if (!NewParams.count(Param))
+            continue;
+
+          AssumptionCtx =
+              isl_set_project_out(AssumptionCtx, isl_dim_param, u--, 1);
+        }
       }
-    }
 
-    emitOptimizationRemarkAnalysis(
-        F.getContext(), DEBUG_TYPE, F, CI->getDebugLoc(),
-        "Use user assumption: " + stringFromIslObj(AssumptionCtx));
-    Context = isl_set_intersect(Context, AssumptionCtx);
+      emitOptimizationRemarkAnalysis(
+          F.getContext(), DEBUG_TYPE, F, CI->getDebugLoc(),
+          "Use user assumption: " + stringFromIslObj(AssumptionCtx));
+      Context = isl_set_intersect(Context, AssumptionCtx);
+    }
   }
 }
 
@@ -3238,14 +3244,13 @@ void Scop::finalizeAccesses() {
   assumeNoOutOfBounds();
 }
 
-void Scop::init(AliasAnalysis &AA, AssumptionCache &AC, DominatorTree &DT,
-                LoopInfo &LI) {
+void Scop::init(AliasAnalysis &AA, DominatorTree &DT, LoopInfo &LI) {
   buildInvariantEquivalenceClasses();
 
   if (!buildDomains(&R, DT, LI))
     return;
 
-  addUserAssumptions(AC, DT, LI);
+  addUserAssumptions(DT, LI);
 
   // Remove empty statements.
   // Exit early in case there are no executable statements left in this scop.
@@ -4518,7 +4523,6 @@ void ScopInfoRegionPass::getAnalysisUsag
   AU.addRequiredTransitive<ScalarEvolutionWrapperPass>();
   AU.addRequiredTransitive<ScopDetection>();
   AU.addRequired<AAResultsWrapperPass>();
-  AU.addRequired<AssumptionCacheTracker>();
   AU.setPreservesAll();
 }
 
@@ -4534,9 +4538,8 @@ bool ScopInfoRegionPass::runOnRegion(Reg
   auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
   auto const &DL = F->getParent()->getDataLayout();
   auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(*F);
 
-  ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE);
+  ScopBuilder SB(R, AA, DL, DT, LI, SD, SE);
   S = SB.getScop(); // take ownership of scop object
   return false;
 }
@@ -4556,7 +4559,6 @@ INITIALIZE_PASS_BEGIN(ScopInfoRegionPass
                       "Polly - Create polyhedral description of Scops", false,
                       false);
 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass);
-INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker);
 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
 INITIALIZE_PASS_DEPENDENCY(RegionInfoPass);
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass);
@@ -4574,7 +4576,6 @@ void ScopInfoWrapperPass::getAnalysisUsa
   AU.addRequiredTransitive<ScalarEvolutionWrapperPass>();
   AU.addRequiredTransitive<ScopDetection>();
   AU.addRequired<AAResultsWrapperPass>();
-  AU.addRequired<AssumptionCacheTracker>();
   AU.setPreservesAll();
 }
 
@@ -4586,7 +4587,6 @@ bool ScopInfoWrapperPass::runOnFunction(
   auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
   auto const &DL = F.getParent()->getDataLayout();
   auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
 
   /// Create polyhedral descripton of scops for all the valid regions of a
   /// function.
@@ -4595,7 +4595,7 @@ bool ScopInfoWrapperPass::runOnFunction(
     if (!SD.isMaxRegionInScop(*R))
       continue;
 
-    ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE);
+    ScopBuilder SB(R, AA, DL, DT, LI, SD, SE);
     std::unique_ptr<Scop> S = SB.getScop();
     if (!S)
       continue;
@@ -4627,7 +4627,6 @@ INITIALIZE_PASS_BEGIN(
     "Polly - Create polyhedral description of all Scops of a function", false,
     false);
 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass);
-INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker);
 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
 INITIALIZE_PASS_DEPENDENCY(RegionInfoPass);
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass);




More information about the llvm-commits mailing list