mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
ScopDetect/Info: Add option to disable invariant load hoisting
This is helpful for test case reduction and other experiments. llvm-svn: 262033
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3116,27 +3116,28 @@ void Scop::verifyInvariantLoads(ScopDetection &SD) {
|
||||
}
|
||||
|
||||
void Scop::hoistInvariantLoads(ScopDetection &SD) {
|
||||
isl_union_map *Writes = getWrites();
|
||||
for (ScopStmt &Stmt : *this) {
|
||||
if (PollyInvariantLoadHoisting) {
|
||||
isl_union_map *Writes = getWrites();
|
||||
for (ScopStmt &Stmt : *this) {
|
||||
MemoryAccessList InvariantAccesses;
|
||||
|
||||
MemoryAccessList InvariantAccesses;
|
||||
for (MemoryAccess *Access : Stmt)
|
||||
if (isHoistableAccess(Access, Writes))
|
||||
InvariantAccesses.push_front(Access);
|
||||
|
||||
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();
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user