[polly] r269049 - Refactor simplifySCoP [NFC]
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue May 10 05:19:47 PDT 2016
Author: jdoerfert
Date: Tue May 10 07:19:47 2016
New Revision: 269049
URL: http://llvm.org/viewvc/llvm-project?rev=269049&view=rev
Log:
Refactor simplifySCoP [NFC]
Remove obsolete code and decrease the indention in the
Scop::simplifySCoP() function.
Added:
polly/trunk/test/Isl/CodeGen/only_non_affine_error_region.ll
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=269049&r1=269048&r2=269049&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue May 10 07:19:47 2016
@@ -1156,10 +1156,6 @@ public:
/// statements, return its entry block.
BasicBlock *getEntryBlock() const;
- /// @brief Return RegionInfo's RegionNode for this statements' BB or
- /// subregion.
- RegionNode *getRegionNode() const;
-
/// @brief Return true if this statement does not contain any accesses.
bool isEmpty() const { return MemAccs.empty(); }
@@ -1614,28 +1610,11 @@ private:
bool buildDomains(Region *R, ScopDetection &SD, DominatorTree &DT,
LoopInfo &LI);
- /// @brief Check if a region part should be represented in the SCoP or not.
- ///
- /// If @p RN does not contain any useful calculation or is only reachable
- /// via error blocks we do not model it in the polyhedral representation.
- ///
- /// @param RN The region part to check.
- /// @param DT The DominatorTree for the current function.
- /// @param LI The LoopInfo for the current function.
- ///
- /// @return True if the part should be ignored, otherwise false.
- bool isIgnored(RegionNode *RN, DominatorTree &DT, LoopInfo &LI);
-
/// @brief Add parameter constraints to @p C that imply a non-empty domain.
__isl_give isl_set *addNonEmptyDomainConstraints(__isl_take isl_set *C) const;
/// @brief Simplify the SCoP representation
- ///
- /// At the moment we perform the following simplifications:
- /// - removal of no-op statements
- /// @param RemoveIgnoredStmts If true, also removed ignored statments.
- /// @see isIgnored()
- void simplifySCoP(bool RemoveIgnoredStmts, DominatorTree &DT, LoopInfo &LI);
+ void simplifySCoP(bool AfterHoisting, DominatorTree &DT, LoopInfo &LI);
/// @brief Create equivalence classes for required invariant accesses.
///
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=269049&r1=269048&r2=269049&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue May 10 07:19:47 2016
@@ -1657,12 +1657,6 @@ BasicBlock *ScopStmt::getEntryBlock() co
return getRegion()->getEntry();
}
-RegionNode *ScopStmt::getRegionNode() const {
- if (isRegionStmt())
- return getRegion()->getNode();
- return getParent()->getRegion().getBBNode(getBasicBlock());
-}
-
unsigned ScopStmt::getNumParams() const { return Parent.getNumParams(); }
unsigned ScopStmt::getNumIterators() const { return NestLoops.size(); }
@@ -2274,7 +2268,7 @@ bool Scop::buildDomains(Region *R, ScopD
DomainMap[EntryBB] = S;
if (IsOnlyNonAffineRegion)
- return true;
+ return !containsErrorBlock(R->getNode(), *R, LI, DT);
if (!buildDomainsWithBranchConstraints(R, SD, DT, LI))
return false;
@@ -3087,9 +3081,9 @@ void Scop::init(AliasAnalysis &AA, Assum
addUserAssumptions(AC, DT, LI);
- // Remove empty and ignored statements.
+ // Remove empty statements.
// Exit early in case there are no executable statements left in this scop.
- simplifySCoP(true, DT, LI);
+ simplifySCoP(false, DT, LI);
if (Stmts.empty())
return;
@@ -3116,7 +3110,7 @@ void Scop::init(AliasAnalysis &AA, Assum
hoistInvariantLoads(SD);
verifyInvariantLoads(SD);
- simplifySCoP(false, DT, LI);
+ simplifySCoP(true, DT, LI);
}
Scop::~Scop() {
@@ -3180,20 +3174,16 @@ void Scop::updateAccessDimensionality()
Access->updateDimensionality();
}
-void Scop::simplifySCoP(bool RemoveIgnoredStmts, DominatorTree &DT,
- LoopInfo &LI) {
+void Scop::simplifySCoP(bool AfterHoisting, DominatorTree &DT, LoopInfo &LI) {
for (auto StmtIt = Stmts.begin(), StmtEnd = Stmts.end(); StmtIt != StmtEnd;) {
ScopStmt &Stmt = *StmtIt;
- RegionNode *RN = Stmt.getRegionNode();
- bool RemoveStmt = StmtIt->isEmpty();
+ bool RemoveStmt = Stmt.isEmpty();
if (!RemoveStmt)
RemoveStmt = isl_set_is_empty(DomainMap[Stmt.getEntryBlock()]);
- if (!RemoveStmt)
- RemoveStmt = (RemoveIgnoredStmts && isIgnored(RN, DT, LI));
// Remove read only statements only after invariant loop hoisting.
- if (!RemoveStmt && !RemoveIgnoredStmts) {
+ if (!RemoveStmt && AfterHoisting) {
bool OnlyRead = true;
for (MemoryAccess *MA : Stmt) {
if (MA->isRead())
@@ -3206,19 +3196,19 @@ void Scop::simplifySCoP(bool RemoveIgnor
RemoveStmt = OnlyRead;
}
- if (RemoveStmt) {
- // 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);
+ if (!RemoveStmt) {
+ StmtIt++;
continue;
}
- StmtIt++;
+ // 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);
}
}
@@ -3922,29 +3912,6 @@ bool Scop::restrictDomains(__isl_take is
ScalarEvolution *Scop::getSE() const { return SE; }
-bool Scop::isIgnored(RegionNode *RN, DominatorTree &DT, LoopInfo &LI) {
- BasicBlock *BB = getRegionNodeBasicBlock(RN);
- ScopStmt *Stmt = getStmtFor(RN);
-
- // If there is no stmt, then it already has been removed.
- if (!Stmt)
- return true;
-
- // Check if there are accesses contained.
- if (Stmt->isEmpty())
- return true;
-
- // Check for reachability via non-error blocks.
- if (!DomainMap.count(BB))
- return true;
-
- // Check if error blocks are contained.
- if (containsErrorBlock(RN, getRegion(), LI, DT))
- return true;
-
- return false;
-}
-
struct MapToDimensionDataTy {
int N;
isl_union_pw_multi_aff *Res;
Added: polly/trunk/test/Isl/CodeGen/only_non_affine_error_region.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/only_non_affine_error_region.ll?rev=269049&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/only_non_affine_error_region.ll (added)
+++ polly/trunk/test/Isl/CodeGen/only_non_affine_error_region.ll Tue May 10 07:19:47 2016
@@ -0,0 +1,31 @@
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+;
+; CHECK-NOT: polly.start
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; Function Attrs: nounwind uwtable
+define void @f(i32 %argc, i32* %A) #0 {
+entry:
+ br i1 undef, label %for.end, label %for.body
+
+for.body: ; preds = %entry
+ br label %for.end
+
+for.end: ; preds = %for.body, %entry
+ %i.2 = phi i32 [ 1, %entry ], [ 1, %for.body ]
+ %cmp170 = icmp eq i32 %i.2, %argc
+ br i1 %cmp170, label %if.then172, label %if.end174
+
+if.then172: ; preds = %for.end
+ %0 = load i32, i32* %A
+ tail call void @usage()
+ br label %if.end174
+
+if.end174: ; preds = %if.then172, %for.end
+ %idxprom175 = sext i32 %i.2 to i64
+ ret void
+}
+
+; Function Attrs: nounwind uwtable
+declare void @usage()
More information about the llvm-commits
mailing list