summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-05-23 12:40:48 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-05-23 12:40:48 +0000
commit952b5304bc9cb73e9285eb34f9c4403d5d50fc94 (patch)
tree1bcc8b248cb99d47054a40adaa7649d4c0b113b1
parente6f4d28d6a03869549f665d1faf0e497923ff8e1 (diff)
downloadbcm5719-llvm-952b5304bc9cb73e9285eb34f9c4403d5d50fc94.tar.gz
bcm5719-llvm-952b5304bc9cb73e9285eb34f9c4403d5d50fc94.zip
Add and use Scop::contains(Loop/BasicBlock/Instruction) [NFC]
llvm-svn: 270424
-rw-r--r--polly/include/polly/ScopInfo.h9
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp28
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp12
-rw-r--r--polly/lib/CodeGen/IslNodeBuilder.cpp11
-rw-r--r--polly/lib/Support/SCEVAffinator.cpp2
5 files changed, 34 insertions, 28 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 67d4d4ce26e..8135790d88b 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -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.
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index dc622db9387..bfc0f0f8a0f 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -155,7 +155,7 @@ static const ScopArrayInfo *identifyBasePtrOriginSAI(Scop *S, Value *BasePtr) {
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(AssumptionCache &AC, DominatorTree &DT,
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(AssumptionCache &AC, DominatorTree &DT,
}
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(AssumptionCache &AC, DominatorTree &DT,
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::propagateDomainConstraintsToRegionExit(
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(Region *R, DominatorTree &DT,
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(MemoryAccess *MA,
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::getNonHoistableCtx(MemoryAccess *Access,
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, LoopStackTy &LoopStack, LoopInfo &LI) {
}
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(Instruction *Inst) {
// 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.
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 569279b85ea..8df0e830b9a 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -127,7 +127,7 @@ Value *BlockGenerator::getNewValue(ScopStmt &Stmt, Value *Old, ValueMapT &BBMap,
// 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(const Scop &S, Instruction *Inst) {
if (EscapeMap.count(Inst))
return;
- const auto &R = S.getRegion();
EscapeUserVectorTy EscapeUsers;
for (User *U : Inst->users()) {
@@ -378,7 +377,7 @@ void BlockGenerator::handleOutsideUsers(const Scop &S, Instruction *Inst) {
if (!UI)
continue;
- if (R.contains(UI))
+ if (S.contains(UI))
continue;
EscapeUsers.push_back(UI);
@@ -477,7 +476,7 @@ void BlockGenerator::createScalarInitialization(Scop &S) {
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::createScalarInitialization(Scop &S) {
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::createScalarFinalization(Region &R) {
}
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(Scop &S) {
// 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);
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index 17afa1724f2..c98463164ab 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -229,7 +229,7 @@ static isl_stat addReferencesFromStmt(const ScopStmt *Stmt, void *UserPtr) {
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::getReferencesInSubtree(__isl_keep isl_ast_node *For,
/// 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(isl_id *Id) {
// 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::preloadInvariantEquivClass(
}
}
- const Region &R = S.getRegion();
for (const MemoryAccess *MA : MAs) {
Instruction *MAAccInst = MA->getAccessInstruction();
@@ -1155,7 +1154,7 @@ bool IslNodeBuilder::preloadInvariantEquivClass(
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_take isl_set *Context) {
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) {
diff --git a/polly/lib/Support/SCEVAffinator.cpp b/polly/lib/Support/SCEVAffinator.cpp
index 47a42c7b58e..cd95945e2cb 100644
--- a/polly/lib/Support/SCEVAffinator.cpp
+++ b/polly/lib/Support/SCEVAffinator.cpp
@@ -437,7 +437,7 @@ __isl_give PWACtx SCEVAffinator::visitAddRecExpr(const SCEVAddRecExpr *Expr) {
// 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));
OpenPOWER on IntegriCloud