summaryrefslogtreecommitdiffstats
path: root/polly/lib
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib')
-rw-r--r--polly/lib/Analysis/ScopBuilder.cpp17
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp45
2 files changed, 18 insertions, 44 deletions
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index aa114527e6c..3d1e292b757 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -1190,10 +1190,21 @@ void ScopBuilder::buildDomain(ScopStmt &Stmt) {
void ScopBuilder::collectSurroundingLoops(ScopStmt &Stmt) {
isl::set Domain = Stmt.getDomain();
- for (unsigned u = 0, e = Domain.dim(isl::dim::set); u < e; u++) {
- isl::id DimId = Domain.get_dim_id(isl::dim::set, u);
- Stmt.NestLoops.push_back(static_cast<Loop *>(DimId.get_user()));
+ BasicBlock *BB = Stmt.getEntryBlock();
+
+ Loop *L = LI.getLoopFor(BB);
+
+ while (L && Stmt.isRegionStmt() && Stmt.getRegion()->contains(L))
+ L = L->getParentLoop();
+
+ SmallVector<llvm::Loop *, 8> Loops;
+
+ while (L && Stmt.getParent()->getRegion().contains(L)) {
+ Loops.push_back(L);
+ L = L->getParentLoop();
}
+
+ Stmt.NestLoops.insert(Stmt.NestLoops.begin(), Loops.rbegin(), Loops.rend());
}
/// Return the reduction type for a given binary operator.
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 9c0a037c213..e68551b470f 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1372,16 +1372,6 @@ partitionSetParts(__isl_take isl_set *S, unsigned Dim) {
return std::make_pair(UnboundedParts, BoundedParts);
}
-/// Set the dimension Ids from @p From in @p To.
-static __isl_give isl_set *setDimensionIds(__isl_keep isl_set *From,
- __isl_take isl_set *To) {
- for (unsigned u = 0, e = isl_set_n_dim(From); u < e; u++) {
- isl_id *DimId = isl_set_get_dim_id(From, isl_dim_set, u);
- To = isl_set_set_dim_id(To, isl_dim_set, u, DimId);
- }
- return To;
-}
-
/// Create the conditions under which @p L @p Pred @p R is true.
static __isl_give isl_set *buildConditionSet(ICmpInst::Predicate Pred,
__isl_take isl_pw_aff *L,
@@ -1412,18 +1402,6 @@ static __isl_give isl_set *buildConditionSet(ICmpInst::Predicate Pred,
}
}
-/// Create the conditions under which @p L @p Pred @p R is true.
-///
-/// Helper function that will make sure the dimensions of the result have the
-/// same isl_id's as the @p Domain.
-static __isl_give isl_set *buildConditionSet(ICmpInst::Predicate Pred,
- __isl_take isl_pw_aff *L,
- __isl_take isl_pw_aff *R,
- __isl_keep isl_set *Domain) {
- isl_set *ConsequenceCondSet = buildConditionSet(Pred, L, R);
- return setDimensionIds(Domain, ConsequenceCondSet);
-}
-
/// Compute the isl representation for the SCEV @p E in this BB.
///
/// @param S The Scop in which @p BB resides in.
@@ -1468,7 +1446,7 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, SwitchInst *SI, Loop *L,
RHS = getPwAff(S, BB, InvalidDomainMap, SE.getSCEV(CaseValue));
isl_set *CaseConditionSet =
- buildConditionSet(ICmpInst::ICMP_EQ, isl_pw_aff_copy(LHS), RHS, Domain);
+ buildConditionSet(ICmpInst::ICMP_EQ, isl_pw_aff_copy(LHS), RHS);
ConditionSets[Idx] = isl_set_coalesce(
isl_set_intersect(CaseConditionSet, isl_set_copy(Domain)));
}
@@ -1478,8 +1456,7 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, SwitchInst *SI, Loop *L,
for (unsigned u = 2; u < NumSuccessors; u++)
ConditionSetUnion =
isl_set_union(ConditionSetUnion, isl_set_copy(ConditionSets[u]));
- ConditionSets[0] = setDimensionIds(
- Domain, isl_set_subtract(isl_set_copy(Domain), ConditionSetUnion));
+ ConditionSets[0] = isl_set_subtract(isl_set_copy(Domain), ConditionSetUnion);
isl_pw_aff_free(LHS);
@@ -1522,7 +1499,6 @@ buildUnsignedConditionSets(Scop &S, BasicBlock *BB, Value *Condition,
Second = isl_pw_aff_le_set(TestVal, UpperBound);
isl_set *ConsequenceCondSet = isl_set_intersect(First, Second);
- ConsequenceCondSet = setDimensionIds(Domain, ConsequenceCondSet);
return ConsequenceCondSet;
}
@@ -1547,8 +1523,7 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition,
bool NonNeg = false;
isl_pw_aff *LHS = getPwAff(S, BB, InvalidDomainMap, LHSSCEV, NonNeg);
isl_pw_aff *RHS = getPwAff(S, BB, InvalidDomainMap, RHSSCEV, NonNeg);
- ConsequenceCondSet =
- buildConditionSet(ICmpInst::ICMP_SLE, LHS, RHS, Domain);
+ ConsequenceCondSet = buildConditionSet(ICmpInst::ICMP_SLE, LHS, RHS);
} else if (auto *PHI = dyn_cast<PHINode>(Condition)) {
auto *Unique = dyn_cast<ConstantInt>(
getUniqueNonErrorValue(PHI, &S.getRegion(), *S.getLI(), *S.getDT()));
@@ -1629,8 +1604,7 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition,
default:
LHS = getPwAff(S, BB, InvalidDomainMap, LeftOperand, NonNeg);
RHS = getPwAff(S, BB, InvalidDomainMap, RightOperand, NonNeg);
- ConsequenceCondSet =
- buildConditionSet(ICond->getPredicate(), LHS, RHS, Domain);
+ ConsequenceCondSet = buildConditionSet(ICond->getPredicate(), LHS, RHS);
break;
}
}
@@ -2518,14 +2492,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);
-}
-
isl::set Scop::getDomainConditions(const ScopStmt *Stmt) const {
return getDomainConditions(Stmt->getEntryBlock());
}
@@ -2551,7 +2517,6 @@ bool Scop::buildDomains(Region *R, DominatorTree &DT, LoopInfo &LI,
auto *S = isl_set_universe(isl_space_set_alloc(getIslCtx().get(), 0, LD + 1));
while (LD-- >= 0) {
- S = addDomainDimId(S, LD + 1, L);
L = L->getParentLoop();
}
@@ -2614,7 +2579,6 @@ static __isl_give isl_set *adjustDomainDimensions(Scop &S,
assert(OldL->getParentLoop() == NewL->getParentLoop());
Dom = isl_set_project_out(Dom, isl_dim_set, NewDepth, 1);
Dom = isl_set_add_dims(Dom, isl_dim_set, 1);
- Dom = addDomainDimId(Dom, NewDepth, NewL);
} else if (OldDepth < NewDepth) {
assert(OldDepth + 1 == NewDepth);
auto &R = S.getRegion();
@@ -2622,7 +2586,6 @@ static __isl_give isl_set *adjustDomainDimensions(Scop &S,
assert(NewL->getParentLoop() == OldL ||
((!OldL || !R.contains(OldL)) && R.contains(NewL)));
Dom = isl_set_add_dims(Dom, isl_dim_set, 1);
- Dom = addDomainDimId(Dom, NewDepth, NewL);
} else {
assert(OldDepth > NewDepth);
int Diff = OldDepth - NewDepth;
OpenPOWER on IntegriCloud