[polly] r302276 - [ScopBuilder] Move Scop::init to ScopBuilder. NFC.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 13:09:08 PDT 2017
Author: meinersbur
Date: Fri May 5 15:09:08 2017
New Revision: 302276
URL: http://llvm.org/viewvc/llvm-project?rev=302276&view=rev
Log:
[ScopBuilder] Move Scop::init to ScopBuilder. NFC.
Scop::init is used only during SCoP construction. Therefore ScopBuilder
seems the more appropriate place for it. We integrate it onto its only
caller ScopBuilder::buildScop where some other construction steps
already took place.
Differential Revision: https://reviews.llvm.org/D32908
Modified:
polly/trunk/lib/Analysis/ScopBuilder.cpp
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=302276&r1=302275&r2=302276&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Fri May 5 15:09:08 2017
@@ -37,6 +37,11 @@ static cl::opt<bool> ModelReadOnlyScalar
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,
/// 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, A
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);
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=302276&r1=302275&r2=302276&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri May 5 15:09:08 2017
@@ -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);
More information about the llvm-commits
mailing list