[polly] r266741 - Relate domains to statements during construction [NFC]
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 07:53:13 PDT 2016
Author: jdoerfert
Date: Tue Apr 19 09:53:13 2016
New Revision: 266741
URL: http://llvm.org/viewvc/llvm-project?rev=266741&view=rev
Log:
Relate domains to statements during construction [NFC]
Instead of the Scop::getPwAff() function we now use the ScopStmt::getPwAff()
function during the statements domain construction.
Modified:
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=266741&r1=266740&r2=266741&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Apr 19 09:53:13 2016
@@ -1220,16 +1220,17 @@ static __isl_give isl_set *buildConditio
/// will be moved from @p SI to its successors. Hence, @p ConditionSets will
/// have as many elements as @p SI has successors.
static void
-buildConditionSets(Scop &S, SwitchInst *SI, Loop *L, __isl_keep isl_set *Domain,
+buildConditionSets(ScopStmt &Stmt, SwitchInst *SI, Loop *L,
+ __isl_keep isl_set *Domain,
SmallVectorImpl<__isl_give isl_set *> &ConditionSets) {
Value *Condition = getConditionFromTerminator(SI);
assert(Condition && "No condition for switch");
+ Scop &S = *Stmt.getParent();
ScalarEvolution &SE = *S.getSE();
- BasicBlock *BB = SI->getParent();
isl_pw_aff *LHS, *RHS;
- LHS = S.getPwAff(SE.getSCEVAtScope(Condition, L), BB);
+ LHS = Stmt.getPwAff(SE.getSCEVAtScope(Condition, L));
unsigned NumSuccessors = SI->getNumSuccessors();
ConditionSets.resize(NumSuccessors);
@@ -1237,7 +1238,7 @@ buildConditionSets(Scop &S, SwitchInst *
unsigned Idx = Case.getSuccessorIndex();
ConstantInt *CaseValue = Case.getCaseValue();
- RHS = S.getPwAff(SE.getSCEV(CaseValue), BB);
+ RHS = Stmt.getPwAff(SE.getSCEV(CaseValue));
isl_set *CaseConditionSet =
buildConditionSet(ICmpInst::ICMP_EQ, isl_pw_aff_copy(LHS), RHS, Domain);
ConditionSets[Idx] = isl_set_coalesce(
@@ -1264,10 +1265,11 @@ buildConditionSets(Scop &S, SwitchInst *
/// context under which @p Condition is true/false will be returned as the
/// new elements of @p ConditionSets.
static void
-buildConditionSets(Scop &S, Value *Condition, TerminatorInst *TI, Loop *L,
- __isl_keep isl_set *Domain,
+buildConditionSets(ScopStmt &Stmt, Value *Condition, TerminatorInst *TI,
+ Loop *L, __isl_keep isl_set *Domain,
SmallVectorImpl<__isl_give isl_set *> &ConditionSets) {
+ Scop &S = *Stmt.getParent();
isl_set *ConsequenceCondSet = nullptr;
if (auto *CCond = dyn_cast<ConstantInt>(Condition)) {
if (CCond->isZero())
@@ -1278,8 +1280,10 @@ buildConditionSets(Scop &S, Value *Condi
auto Opcode = BinOp->getOpcode();
assert(Opcode == Instruction::And || Opcode == Instruction::Or);
- buildConditionSets(S, BinOp->getOperand(0), TI, L, Domain, ConditionSets);
- buildConditionSets(S, BinOp->getOperand(1), TI, L, Domain, ConditionSets);
+ buildConditionSets(Stmt, BinOp->getOperand(0), TI, L, Domain,
+ ConditionSets);
+ buildConditionSets(Stmt, BinOp->getOperand(1), TI, L, Domain,
+ ConditionSets);
isl_set_free(ConditionSets.pop_back_val());
isl_set *ConsCondPart0 = ConditionSets.pop_back_val();
@@ -1296,10 +1300,9 @@ buildConditionSets(Scop &S, Value *Condi
"Condition of exiting branch was neither constant nor ICmp!");
ScalarEvolution &SE = *S.getSE();
- BasicBlock *BB = TI ? TI->getParent() : nullptr;
isl_pw_aff *LHS, *RHS;
- LHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(0), L), BB);
- RHS = S.getPwAff(SE.getSCEVAtScope(ICond->getOperand(1), L), BB);
+ LHS = Stmt.getPwAff(SE.getSCEVAtScope(ICond->getOperand(0), L));
+ RHS = Stmt.getPwAff(SE.getSCEVAtScope(ICond->getOperand(1), L));
ConsequenceCondSet =
buildConditionSet(ICond->getPredicate(), LHS, RHS, Domain);
}
@@ -1333,12 +1336,12 @@ buildConditionSets(Scop &S, Value *Condi
/// will be moved from @p TI to its successors. Hence, @p ConditionSets will
/// have as many elements as @p TI has successors.
static void
-buildConditionSets(Scop &S, TerminatorInst *TI, Loop *L,
+buildConditionSets(ScopStmt &Stmt, TerminatorInst *TI, Loop *L,
__isl_keep isl_set *Domain,
SmallVectorImpl<__isl_give isl_set *> &ConditionSets) {
if (SwitchInst *SI = dyn_cast<SwitchInst>(TI))
- return buildConditionSets(S, SI, L, Domain, ConditionSets);
+ return buildConditionSets(Stmt, SI, L, Domain, ConditionSets);
assert(isa<BranchInst>(TI) && "Terminator was neither branch nor switch.");
@@ -1350,7 +1353,7 @@ buildConditionSets(Scop &S, TerminatorIn
Value *Condition = getConditionFromTerminator(TI);
assert(Condition && "No condition for Terminator");
- return buildConditionSets(S, Condition, TI, L, Domain, ConditionSets);
+ return buildConditionSets(Stmt, Condition, TI, L, Domain, ConditionSets);
}
void ScopStmt::buildDomain() {
@@ -1870,7 +1873,7 @@ void Scop::addUserAssumptions(Assumption
addParams(Params);
SmallVector<isl_set *, 2> ConditionSets;
- buildConditionSets(*this, Val, nullptr, L, Context, ConditionSets);
+ buildConditionSets(*Stmts.begin(), Val, nullptr, L, Context, ConditionSets);
assert(ConditionSets.size() == 2);
isl_set_free(ConditionSets[1]);
@@ -2478,7 +2481,7 @@ bool Scop::buildDomainsWithBranchConstra
if (RN->isSubRegion())
ConditionSets.push_back(isl_set_copy(Domain));
else
- buildConditionSets(*this, TI, BBLoop, Domain, ConditionSets);
+ buildConditionSets(*getStmtFor(BB), TI, BBLoop, Domain, ConditionSets);
// Now iterate over the successors and set their initial domain based on
// their condition set. We skip back edges here and have to be careful when
@@ -2697,7 +2700,8 @@ void Scop::addLoopBoundsToHeaderDomain(L
else {
SmallVector<isl_set *, 8> ConditionSets;
int idx = BI->getSuccessor(0) != HeaderBB;
- buildConditionSets(*this, TI, L, LatchBBDom, ConditionSets);
+ buildConditionSets(*getStmtFor(LatchBB), TI, L, LatchBBDom,
+ ConditionSets);
// Free the non back edge condition set as we do not need it.
isl_set_free(ConditionSets[1 - idx]);
More information about the llvm-commits
mailing list