aboutsummaryrefslogtreecommitdiff
path: root/polly
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2017-07-16 23:55:38 +0000
committerTobias Grosser <tobias@grosser.es>2017-07-16 23:55:38 +0000
commit21cbcf03d31412be7343db749ef0342f8a6e29f4 (patch)
tree74abd6afe655758775fe6c5b6c469af6fdc731f4 /polly
parent5c8a50bddd973e5ea126758c346423b5b901bd21 (diff)
downloadllvm-21cbcf03d31412be7343db749ef0342f8a6e29f4.zip
llvm-21cbcf03d31412be7343db749ef0342f8a6e29f4.tar.gz
llvm-21cbcf03d31412be7343db749ef0342f8a6e29f4.tar.bz2
ScopInfo: Remove not-in-DomainMap statements in separate function
This separates ScopBuilder internal and ScopBuilder external functionality. llvm-svn: 308152
Diffstat (limited to 'polly')
-rw-r--r--polly/include/polly/ScopInfo.h13
-rw-r--r--polly/lib/Analysis/ScopBuilder.cpp1
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp49
3 files changed, 45 insertions, 18 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 449d091..bc77bbf 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -2148,6 +2148,19 @@ private:
/// all memory accesses have been modeled and canonicalized.
void assumeNoOutOfBounds();
+ /// Remove statements from the list of scop statements.
+ ///
+ /// @param ShouldDelete A function that returns true if the statement passed
+ /// to it should be deleted.
+ void removeStmts(std::function<bool(ScopStmt &)> ShouldDelete);
+
+ /// Removes @p Stmt from the StmtMap.
+ void removeFromStmtMap(ScopStmt &Stmt);
+
+ /// Removes all statements where the entry block of the statement does not
+ /// have a corresponding domain in the domain map.
+ void removeStmtNotInDomainMap();
+
/// Mark arrays that have memory accesses with FortranArrayDescriptor.
void markFortranArrays();
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 002a9b5..f33a28b 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -982,6 +982,7 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
// Remove empty statements.
// Exit early in case there are no executable statements left in this scop.
+ scop->removeStmtNotInDomainMap();
scop->simplifySCoP(false);
if (scop->isEmpty())
return;
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 523bd80..0578edb 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -3728,13 +3728,37 @@ void Scop::assumeNoOutOfBounds() {
Access->assumeNoOutOfBound();
}
-void Scop::simplifySCoP(bool AfterHoisting) {
+void Scop::removeFromStmtMap(ScopStmt &Stmt) {
+ if (Stmt.isRegionStmt())
+ for (BasicBlock *BB : Stmt.getRegion()->blocks())
+ StmtMap.erase(BB);
+ else
+ StmtMap.erase(Stmt.getBasicBlock());
+}
+
+void Scop::removeStmts(std::function<bool(ScopStmt &)> ShouldDelete) {
for (auto StmtIt = Stmts.begin(), StmtEnd = Stmts.end(); StmtIt != StmtEnd;) {
- ScopStmt &Stmt = *StmtIt;
+ if (!ShouldDelete(*StmtIt)) {
+ StmtIt++;
+ continue;
+ }
+ removeFromStmtMap(*StmtIt);
+ StmtIt = Stmts.erase(StmtIt);
+ }
+}
+
+void Scop::removeStmtNotInDomainMap() {
+ auto ShouldDelete = [this](ScopStmt &Stmt) -> bool {
+ return !this->DomainMap[Stmt.getEntryBlock()];
+ };
+ removeStmts(ShouldDelete);
+}
+
+void Scop::simplifySCoP(bool AfterHoisting) {
+
+ auto ShouldDelete = [AfterHoisting](ScopStmt &Stmt) -> bool {
bool RemoveStmt = Stmt.isEmpty();
- if (!RemoveStmt)
- RemoveStmt = !DomainMap[Stmt.getEntryBlock()];
// Remove read only statements only after invariant load hoisting.
if (!RemoveStmt && AfterHoisting) {
@@ -3749,21 +3773,10 @@ void Scop::simplifySCoP(bool AfterHoisting) {
RemoveStmt = OnlyRead;
}
+ return RemoveStmt;
+ };
- if (!RemoveStmt) {
- StmtIt++;
- continue;
- }
-
- // Remove the statement because it is unnecessary.
- if (Stmt.isRegionStmt())
- for (BasicBlock *BB : Stmt.getRegion()->blocks())
- StmtMap.erase(BB);
- else
- StmtMap.erase(Stmt.getBasicBlock());
-
- StmtIt = Stmts.erase(StmtIt);
- }
+ removeStmts(ShouldDelete);
}
InvariantEquivClassTy *Scop::lookupInvariantEquivClass(Value *Val) {