summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-02-26 16:43:35 +0000
committerTobias Grosser <tobias@grosser.es>2016-02-26 16:43:35 +0000
commit8fa3e4c3fbab6f429ff8490a2c9487afccd7db83 (patch)
tree3a72e2867f380786817b2fe85a130869de9db6b2
parent0ac2d3e21757038846cdb7c71df2f414b36cfd40 (diff)
downloadbcm5719-llvm-8fa3e4c3fbab6f429ff8490a2c9487afccd7db83.tar.gz
bcm5719-llvm-8fa3e4c3fbab6f429ff8490a2c9487afccd7db83.zip
ScopDetect/Info: Add option to disable invariant load hoisting
This is helpful for test case reduction and other experiments. llvm-svn: 262033
-rw-r--r--polly/include/polly/ScopDetection.h1
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp9
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp41
3 files changed, 31 insertions, 20 deletions
diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h
index 007ade20da6..294157c91cd 100644
--- a/polly/include/polly/ScopDetection.h
+++ b/polly/include/polly/ScopDetection.h
@@ -110,6 +110,7 @@ extern bool PollyTrackFailures;
extern bool PollyDelinearize;
extern bool PollyUseRuntimeAliasChecks;
extern bool PollyProcessUnprofitable;
+extern bool PollyInvariantLoadHoisting;
/// @brief A function attribute which will cause Polly to skip the function
extern llvm::StringRef PollySkipFnAttr;
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index c4484bb4056..7cfb03c93a0 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -171,6 +171,12 @@ static cl::opt<bool>
cl::Hidden, cl::init(false), cl::ZeroOrMore,
cl::cat(PollyCategory));
+bool polly::PollyInvariantLoadHoisting;
+static cl::opt<bool, true> XPollyInvariantLoadHoisting(
+ "polly-invariant-load-hoisting", cl::desc("Hoist invariant loads."),
+ cl::location(PollyInvariantLoadHoisting), cl::Hidden, cl::ZeroOrMore,
+ cl::init(true), cl::cat(PollyCategory));
+
/// @brief The minimal trip count under which loops are considered unprofitable.
static const unsigned MIN_LOOP_TRIP_COUNT = 8;
@@ -304,6 +310,9 @@ bool ScopDetection::onlyValidRequiredInvariantLoads(
InvariantLoadsSetTy &RequiredILS, DetectionContext &Context) const {
Region &CurRegion = Context.CurRegion;
+ if (!PollyInvariantLoadHoisting && !RequiredILS.empty())
+ return false;
+
for (LoadInst *Load : RequiredILS)
if (!isHoistableLoad(Load, CurRegion, *LI, *SE))
return false;
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index e48f87c0442..71f1b626d4c 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -3116,27 +3116,28 @@ void Scop::verifyInvariantLoads(ScopDetection &SD) {
}
void Scop::hoistInvariantLoads(ScopDetection &SD) {
- isl_union_map *Writes = getWrites();
- for (ScopStmt &Stmt : *this) {
-
- MemoryAccessList InvariantAccesses;
-
- for (MemoryAccess *Access : Stmt)
- if (isHoistableAccess(Access, Writes))
- InvariantAccesses.push_front(Access);
-
- // We inserted invariant accesses always in the front but need them to be
- // sorted in a "natural order". The statements are already sorted in reverse
- // post order and that suffices for the accesses too. The reason we require
- // an order in the first place is the dependences between invariant loads
- // that can be caused by indirect loads.
- InvariantAccesses.reverse();
-
- // Transfer the memory access from the statement to the SCoP.
- Stmt.removeMemoryAccesses(InvariantAccesses);
- addInvariantLoads(Stmt, InvariantAccesses);
+ if (PollyInvariantLoadHoisting) {
+ isl_union_map *Writes = getWrites();
+ for (ScopStmt &Stmt : *this) {
+ MemoryAccessList InvariantAccesses;
+
+ for (MemoryAccess *Access : Stmt)
+ if (isHoistableAccess(Access, Writes))
+ InvariantAccesses.push_front(Access);
+
+ // We inserted invariant accesses always in the front but need them to be
+ // sorted in a "natural order". The statements are already sorted in
+ // reverse post order and that suffices for the accesses too. The reason
+ // we require an order in the first place is the dependences between
+ // invariant loads that can be caused by indirect loads.
+ InvariantAccesses.reverse();
+
+ // Transfer the memory access from the statement to the SCoP.
+ Stmt.removeMemoryAccesses(InvariantAccesses);
+ addInvariantLoads(Stmt, InvariantAccesses);
+ }
+ isl_union_map_free(Writes);
}
- isl_union_map_free(Writes);
verifyInvariantLoads(SD);
}
OpenPOWER on IntegriCloud