/// 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);
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(
/// 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())
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();
"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);
}
/// 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.");
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() {
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]);
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
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]);