Simplify the SCoP creation and bookkeeping

To avoid multiple exits and the resulting complicated conditions when
  creating a SCoP we now use the single hasFeasibleRuntimeContext()
  check to decide if a SCoP should be dismissed right after
  construction. If building runtime checks failed the assumed context is
  made infeasible, hence the optimized version will never be executed
  and the SCoP can be dismissed.

llvm-svn: 245593
This commit is contained in:
Johannes Doerfert 2015-08-20 18:30:08 +00:00
parent 7230a22d5e
commit 120de4be96
2 changed files with 36 additions and 34 deletions

View File

@ -895,13 +895,14 @@ private:
Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth);
/// @brief Initialize this ScopInfo using a TempScop object.
void initFromTempScop(TempScop &TempScop, LoopInfo &LI, ScopDetection &SD);
void initFromTempScop(TempScop &TempScop, LoopInfo &LI, ScopDetection &SD,
AliasAnalysis &AA);
/// Create the static control part with a region, max loop depth of this
/// region and parameters used in this region.
static Scop *createFromTempScop(TempScop &TempScop, LoopInfo &LI,
ScalarEvolution &SE, ScopDetection &SD,
isl_ctx *ctx);
AliasAnalysis &AA, isl_ctx *ctx);
/// @brief Check if a basic block is trivial.
///
@ -1097,6 +1098,9 @@ public:
/// to hold.
void addAssumption(__isl_take isl_set *Set);
/// @brief Build the alias checks for this SCoP.
void buildAliasChecks(AliasAnalysis &AA);
/// @brief Build all alias groups for this SCoP.
///
/// @returns True if __no__ error occurred, false otherwise.

View File

@ -1346,6 +1346,26 @@ static bool calculateMinMaxAccess(__isl_take isl_union_map *Accesses,
return Valid;
}
void Scop::buildAliasChecks(AliasAnalysis &AA) {
if (!PollyUseRuntimeAliasChecks)
return;
if (buildAliasGroups(AA))
return;
// If a problem occurs while building the alias groups we need to delete
// this SCoP and pretend it wasn't valid in the first place. To this end
// we make the assumed context infeasible.
addAssumption(isl_set_empty(getParamSpace()));
DEBUG(dbgs() << "\n\nNOTE: Run time checks for " << getNameStr()
<< " could not be created as the number of parameters involved "
"is too high. The SCoP will be "
"dismissed.\nUse:\n\t--polly-rtc-max-parameters=X\nto adjust "
"the maximal number of parameters but be advised that the "
"compile time might increase exponentially.\n\n");
}
bool Scop::buildAliasGroups(AliasAnalysis &AA) {
// To create sound alias checks we perform the following steps:
// o) Use the alias analysis and an alias set tracker to build alias sets
@ -1532,7 +1552,7 @@ Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context,
MaxLoopDepth(MaxLoopDepth), IslCtx(Context), Affinator(this) {}
void Scop::initFromTempScop(TempScop &TempScop, LoopInfo &LI,
ScopDetection &SD) {
ScopDetection &SD, AliasAnalysis &AA) {
buildContext();
SmallVector<Loop *, 8> NestLoops;
@ -1547,17 +1567,19 @@ void Scop::initFromTempScop(TempScop &TempScop, LoopInfo &LI,
addParameterBounds();
addUserContext();
simplifyAssumedContext();
buildAliasChecks(AA);
assert(NestLoops.empty() && "NestLoops not empty at top level!");
}
Scop *Scop::createFromTempScop(TempScop &TempScop, LoopInfo &LI,
ScalarEvolution &SE, ScopDetection &SD,
isl_ctx *ctx) {
AliasAnalysis &AA, isl_ctx *ctx) {
auto &R = TempScop.getMaxRegion();
auto MaxLoopDepth = getMaxLoopDepthInRegion(R, LI, SD);
auto S = new Scop(R, SE, ctx, MaxLoopDepth);
S->initFromTempScop(TempScop, LI, SD);
S->initFromTempScop(TempScop, LI, SD, AA);
return S;
}
@ -2064,7 +2086,7 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
return false;
}
scop = Scop::createFromTempScop(*tempScop, LI, SE, SD, ctx);
scop = Scop::createFromTempScop(*tempScop, LI, SE, SD, AA, ctx);
DEBUG(scop->print(dbgs()));
@ -2074,34 +2096,10 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
return false;
}
if (!PollyUseRuntimeAliasChecks) {
// Statistics.
++ScopFound;
if (scop->getMaxLoopDepth() > 0)
++RichScopFound;
return false;
}
// If a problem occurs while building the alias groups we need to delete
// this SCoP and pretend it wasn't valid in the first place.
if (scop->buildAliasGroups(AA)) {
// Statistics.
++ScopFound;
if (scop->getMaxLoopDepth() > 0)
++RichScopFound;
return false;
}
DEBUG(dbgs()
<< "\n\nNOTE: Run time checks for " << scop->getNameStr()
<< " could not be created as the number of parameters involved is too "
"high. The SCoP will be "
"dismissed.\nUse:\n\t--polly-rtc-max-parameters=X\nto adjust the "
"maximal number of parameters but be advised that the compile time "
"might increase exponentially.\n\n");
delete scop;
scop = nullptr;
// Statistics.
++ScopFound;
if (scop->getMaxLoopDepth() > 0)
++RichScopFound;
return false;
}