summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2016-03-22 23:27:42 +0000
committerMichael Kruse <llvm@meinersbur.de>2016-03-22 23:27:42 +0000
commit49a59ca0930f3038e5bfc8cea66f06be957ecf92 (patch)
tree06d7506f07f954ad580f37a12a760f7f281a38f5 /polly/lib/Analysis/ScopInfo.cpp
parent009ea26358bc2a833a518afed4a9625e6aad8025 (diff)
downloadbcm5719-llvm-49a59ca0930f3038e5bfc8cea66f06be957ecf92.tar.gz
bcm5719-llvm-49a59ca0930f3038e5bfc8cea66f06be957ecf92.zip
[ScopInfo] Fix domains after loops.
ISL can conclude additional conditions on parameters from restrictions on loop variables. Such conditions persist when leaving the loop and the loop variable is projected out. This results in a narrower domain for exiting the loop than entering it and is logically impossible for non-infinite loops. We fix this by not adding a lower bound i>=0 when constructing BB domains, but defer it to when also the upper bound it computed, which was done redundantly even before this patch. This reduces the number of LNT fails with -polly-process-unprofitable -polly-position=before-vectorizer from 8 to 6. llvm-svn: 264118
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 9d93982cc50..166b954210f 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -2101,7 +2101,6 @@ static bool containsErrorBlock(RegionNode *RN, const Region &R, LoopInfo &LI,
static inline __isl_give isl_set *addDomainDimId(__isl_take isl_set *Domain,
unsigned Dim, Loop *L) {
- Domain = isl_set_lower_bound_si(Domain, isl_dim_set, Dim, -1);
isl_id *DimId =
isl_id_alloc(isl_set_get_ctx(Domain), nullptr, static_cast<void *>(L));
return isl_set_set_dim_id(Domain, isl_dim_set, Dim, DimId);
@@ -2366,7 +2365,6 @@ void Scop::propagateDomainConstraints(Region *R, ScopDetection &SD,
}
Loop *BBLoop = getRegionNodeLoop(RN, LI);
- int BBLoopDepth = getRelativeLoopDepth(BBLoop);
isl_set *PredDom = isl_set_empty(isl_set_get_space(Domain));
for (auto *PredBB : predecessors(BB)) {
@@ -2383,32 +2381,30 @@ void Scop::propagateDomainConstraints(Region *R, ScopDetection &SD,
if (!PredBBDom) {
// Determine the loop depth of the predecessor and adjust its domain to
- // the domain of the current block. This can mean we have to:
- // o) Drop a dimension if this block is the exit of a loop, not the
- // header of a new loop and the predecessor was part of the loop.
- // o) Add an unconstrainted new dimension if this block is the header
- // of a loop and the predecessor is not part of it.
- // o) Drop the information about the innermost loop dimension when the
- // predecessor and the current block are surrounded by different
- // loops in the same depth.
+ // the domain of the current block. This means we have to:
+ // o) Drop all loop dimension of loops we are leaving.
+ // o) Add a dimension for each loop we are entering.
PredBBDom = getDomainForBlock(PredBB, DomainMap, *R->getRegionInfo());
Loop *PredBBLoop = LI.getLoopFor(PredBB);
while (BoxedLoops.count(PredBBLoop))
PredBBLoop = PredBBLoop->getParentLoop();
- int PredBBLoopDepth = getRelativeLoopDepth(PredBBLoop);
- unsigned LoopDepthDiff = std::abs(BBLoopDepth - PredBBLoopDepth);
- if (BBLoopDepth < PredBBLoopDepth)
- PredBBDom = isl_set_project_out(
- PredBBDom, isl_dim_set, isl_set_n_dim(PredBBDom) - LoopDepthDiff,
- LoopDepthDiff);
- else if (PredBBLoopDepth < BBLoopDepth) {
- assert(LoopDepthDiff == 1);
- PredBBDom = isl_set_add_dims(PredBBDom, isl_dim_set, 1);
- } else if (BBLoop != PredBBLoop && BBLoopDepth >= 0) {
- assert(LoopDepthDiff <= 1);
- PredBBDom = isl_set_drop_constraints_involving_dims(
- PredBBDom, isl_dim_set, BBLoopDepth, 1);
+ Loop *LeaveL = PredBBLoop;
+ while (getRegion().contains(LeaveL) &&
+ (!BBLoop || !LeaveL->contains(BBLoop))) {
+ PredBBDom = isl_set_project_out(PredBBDom, isl_dim_set,
+ isl_set_n_dim(PredBBDom) - 1, 1);
+ LeaveL = LeaveL->getParentLoop();
+ }
+ unsigned CommonDepth = isl_set_n_dim(PredBBDom);
+
+ Loop *EnterL = BBLoop;
+ while (getRegion().contains(EnterL) &&
+ (!PredBBLoop || !EnterL->contains(PredBBLoop))) {
+ PredBBDom =
+ isl_set_insert_dims(PredBBDom, isl_dim_set, CommonDepth, 1);
+ PredBBDom = addDomainDimId(PredBBDom, CommonDepth, EnterL);
+ EnterL = EnterL->getParentLoop();
}
}
OpenPOWER on IntegriCloud