[polly] r261792 - Introduce ScopStmt::getEntryBlock(). NFC.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 14:08:25 PST 2016
Author: meinersbur
Date: Wed Feb 24 16:08:24 2016
New Revision: 261792
URL: http://llvm.org/viewvc/llvm-project?rev=261792&view=rev
Log:
Introduce ScopStmt::getEntryBlock(). NFC.
This replaces an ungly inline ternary operator pattern.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/CodeGen/BlockGenerators.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=261792&r1=261791&r2=261792&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Feb 24 16:08:24 2016
@@ -1077,6 +1077,12 @@ public:
/// @brief Return true if this statement represents a whole region.
bool isRegionStmt() const { return R != nullptr; }
+ /// @brief Return a BasicBlock from this statement.
+ ///
+ /// For block statements, it returns the BasicBlock itself. For subregion
+ /// statements, return its entry block.
+ BasicBlock *getEntryBlock() const;
+
/// @brief Return true if this statement does not contain any accesses.
bool isEmpty() const { return MemAccs.empty(); }
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=261792&r1=261791&r2=261792&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Feb 24 16:08:24 2016
@@ -303,7 +303,7 @@ void MemoryAccess::updateDimensionality(
auto DimsAccess = isl_space_dim(AccessSpace, isl_dim_set);
auto DimsMissing = DimsArray - DimsAccess;
- auto *BB = getStatement()->getParent()->getRegion().getEntry();
+ auto *BB = getStatement()->getEntryBlock();
auto &DL = BB->getModule()->getDataLayout();
unsigned ArrayElemSize = SAI->getElemSizeInBytes();
unsigned ElemBytes = DL.getTypeAllocSize(getElementType());
@@ -966,8 +966,7 @@ isl_map *ScopStmt::getSchedule() const {
}
__isl_give isl_pw_aff *ScopStmt::getPwAff(const SCEV *E) {
- return getParent()->getPwAff(E, isBlockStmt() ? getBasicBlock()
- : getRegion()->getEntry());
+ return getParent()->getPwAff(E, getEntryBlock());
}
void ScopStmt::restrictDomain(__isl_take isl_set *NewDomain) {
@@ -1531,6 +1530,12 @@ std::string ScopStmt::getScheduleStr() c
return Str;
}
+BasicBlock *ScopStmt::getEntryBlock() const {
+ if (isBlockStmt())
+ return getBasicBlock();
+ return getRegion()->getEntry();
+}
+
unsigned ScopStmt::getNumParams() const { return Parent.getNumParams(); }
unsigned ScopStmt::getNumIterators() const { return NestLoops.size(); }
@@ -2111,9 +2116,7 @@ static inline __isl_give isl_set *addDom
}
isl_set *Scop::getDomainConditions(ScopStmt *Stmt) {
- BasicBlock *BB = Stmt->isBlockStmt() ? Stmt->getBasicBlock()
- : Stmt->getRegion()->getEntry();
- return getDomainConditions(BB);
+ return getDomainConditions(Stmt->getEntryBlock());
}
isl_set *Scop::getDomainConditions(BasicBlock *BB) {
@@ -2878,7 +2881,7 @@ void Scop::simplifySCoP(bool RemoveIgnor
bool RemoveStmt = StmtIt->isEmpty();
if (!RemoveStmt)
- RemoveStmt = isl_set_is_empty(DomainMap[getRegionNodeBasicBlock(RN)]);
+ RemoveStmt = isl_set_is_empty(DomainMap[Stmt.getEntryBlock()]);
if (!RemoveStmt)
RemoveStmt = (RemoveIgnoredStmts && isIgnored(RN, DT, LI));
@@ -3011,8 +3014,7 @@ bool Scop::isHoistableAccess(MemoryAcces
// generation would otherwise use the old value.
auto &Stmt = *Access->getStatement();
- BasicBlock *BB =
- Stmt.isBlockStmt() ? Stmt.getBasicBlock() : Stmt.getRegion()->getEntry();
+ BasicBlock *BB = Stmt.getEntryBlock();
if (Access->isScalarKind() || Access->isWrite() || !Access->isAffine())
return false;
@@ -4225,10 +4227,9 @@ void ScopInfo::ensurePHIWrite(PHINode *P
}
MemoryAccess *Acc = addMemoryAccess(
- IncomingStmt->isBlockStmt() ? IncomingBlock
- : IncomingStmt->getRegion()->getEntry(),
- PHI, MemoryAccess::MUST_WRITE, PHI, PHI->getType(), true, PHI,
- ArrayRef<const SCEV *>(), ArrayRef<const SCEV *>(),
+ IncomingStmt->getEntryBlock(), PHI, MemoryAccess::MUST_WRITE, PHI,
+ PHI->getType(), true, PHI, ArrayRef<const SCEV *>(),
+ ArrayRef<const SCEV *>(),
IsExitBlock ? ScopArrayInfo::MK_ExitPHI : ScopArrayInfo::MK_PHI);
assert(Acc);
Acc->addIncoming(IncomingBlock, IncomingValue);
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=261792&r1=261791&r2=261792&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Wed Feb 24 16:08:24 2016
@@ -198,8 +198,7 @@ BlockGenerator::generateLocationAccessed
}
Loop *BlockGenerator::getLoopForStmt(const ScopStmt &Stmt) const {
- auto *StmtBB =
- Stmt.isBlockStmt() ? Stmt.getBasicBlock() : Stmt.getRegion()->getEntry();
+ auto *StmtBB = Stmt.getEntryBlock();
return LI.getLoopFor(StmtBB);
}
More information about the llvm-commits
mailing list