diff options
| -rw-r--r-- | polly/lib/Analysis/ScopBuilder.cpp | 64 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 61 | 
2 files changed, 57 insertions, 68 deletions
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp index 80a659b76fd..1417624fa4d 100644 --- a/polly/lib/Analysis/ScopBuilder.cpp +++ b/polly/lib/Analysis/ScopBuilder.cpp @@ -37,6 +37,11 @@ static cl::opt<bool> ModelReadOnlyScalars(      cl::desc("Model read-only scalar values in the scop description"),      cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::cat(PollyCategory)); +static cl::opt<bool> UnprofitableScalarAccs( +    "polly-unprofitable-scalar-accs", +    cl::desc("Count statements with scalar accesses as not optimizable"), +    cl::Hidden, cl::init(false), cl::cat(PollyCategory)); +  void ScopBuilder::buildPHIAccesses(PHINode *PHI, Region *NonAffineSubRegion,                                     bool IsExitBlock) { @@ -655,12 +660,6 @@ static void verifyUse(Scop *S, Use &Op, LoopInfo &LI) {  /// to pick up the virtual uses. But here in the code generator, this has not  /// happened yet, such that virtual and physical uses are equivalent.  static void verifyUses(Scop *S, LoopInfo &LI, DominatorTree &DT) { -  // We require the SCoP to be fully built. Without feasible context, some -  // construction steps are skipped. In particular, we require error statements -  // to be removed. -  if (!S->hasFeasibleRuntimeContext()) -    return; -    for (auto *BB : S->getRegion().blocks()) {      auto *Stmt = S->getStmtFor(BB);      if (!Stmt) @@ -732,7 +731,58 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {        addArrayAccess(MemAccInst(GlobalRead), MemoryAccess::READ, BP,                       BP->getType(), false, {AF}, {nullptr}, GlobalRead); -  scop->init(AA, AC, DT, LI); +  scop->buildInvariantEquivalenceClasses(); + +  if (!scop->buildDomains(&R, DT, LI)) +    return; + +  scop->addUserAssumptions(AC, DT, LI); + +  // Remove empty statements. +  // Exit early in case there are no executable statements left in this scop. +  scop->simplifySCoP(false); +  if (scop->isEmpty()) +    return; + +  // The ScopStmts now have enough information to initialize themselves. +  for (ScopStmt &Stmt : *scop) +    Stmt.init(LI); + +  // Check early for a feasible runtime context. +  if (!scop->hasFeasibleRuntimeContext()) +    return; + +  // Check early for profitability. Afterwards it cannot change anymore, +  // only the runtime context could become infeasible. +  if (!scop->isProfitable(UnprofitableScalarAccs)) { +    scop->invalidate(PROFITABLE, DebugLoc()); +    return; +  } + +  scop->buildSchedule(LI); + +  scop->finalizeAccesses(); + +  scop->realignParams(); +  scop->addUserContext(); + +  // After the context was fully constructed, thus all our knowledge about +  // the parameters is in there, we add all recorded assumptions to the +  // assumed/invalid context. +  scop->addRecordedAssumptions(); + +  scop->simplifyContexts(); +  if (!scop->buildAliasChecks(AA)) +    return; + +  scop->hoistInvariantLoads(); +  scop->verifyInvariantLoads(); +  scop->simplifySCoP(true); + +  // Check late for a feasible runtime context because profitability did not +  // change. +  if (!scop->hasFeasibleRuntimeContext()) +    return;  #ifndef NDEBUG    verifyUses(scop.get(), LI, DT); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index d70d99f3236..b2e2bc4429d 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -132,11 +132,6 @@ static cl::opt<bool>                      cl::desc("Abort if an isl error is encountered"),                      cl::init(true), cl::cat(PollyCategory)); -static cl::opt<bool> UnprofitableScalarAccs( -    "polly-unprofitable-scalar-accs", -    cl::desc("Count statements with scalar accesses as not optimizable"), -    cl::Hidden, cl::init(false), cl::cat(PollyCategory)); -  static cl::opt<bool> PollyPreciseInbounds(      "polly-precise-inbounds",      cl::desc("Take more precise inbounds assumptions (do not scale well)"), @@ -3365,62 +3360,6 @@ void Scop::finalizeAccesses() {    assumeNoOutOfBounds();  } -void Scop::init(AliasAnalysis &AA, AssumptionCache &AC, DominatorTree &DT, -                LoopInfo &LI) { -  buildInvariantEquivalenceClasses(); - -  if (!buildDomains(&R, DT, LI)) -    return; - -  addUserAssumptions(AC, DT, LI); - -  // Remove empty statements. -  // Exit early in case there are no executable statements left in this scop. -  simplifySCoP(false); -  if (Stmts.empty()) -    return; - -  // The ScopStmts now have enough information to initialize themselves. -  for (ScopStmt &Stmt : Stmts) -    Stmt.init(LI); - -  // Check early for a feasible runtime context. -  if (!hasFeasibleRuntimeContext()) -    return; - -  // Check early for profitability. Afterwards it cannot change anymore, -  // only the runtime context could become infeasible. -  if (!isProfitable(UnprofitableScalarAccs)) { -    invalidate(PROFITABLE, DebugLoc()); -    return; -  } - -  buildSchedule(LI); - -  finalizeAccesses(); - -  realignParams(); -  addUserContext(); - -  // After the context was fully constructed, thus all our knowledge about -  // the parameters is in there, we add all recorded assumptions to the -  // assumed/invalid context. -  addRecordedAssumptions(); - -  simplifyContexts(); -  if (!buildAliasChecks(AA)) -    return; - -  hoistInvariantLoads(); -  verifyInvariantLoads(); -  simplifySCoP(true); - -  // Check late for a feasible runtime context because profitability did not -  // change. -  if (!hasFeasibleRuntimeContext()) -    return; -} -  Scop::~Scop() {    isl_set_free(Context);    isl_set_free(AssumedContext);  | 

