summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp60
1 files changed, 45 insertions, 15 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index ef52bd34a1c..e1ecf350ef6 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -998,35 +998,39 @@ buildConditionSets(Scop &S, SwitchInst *SI, Loop *L, __isl_keep isl_set *Domain,
isl_pw_aff_free(LHS);
}
-/// @brief Build the conditions sets for the terminator @p TI in the @p Domain.
+/// @brief Build the conditions sets for the branch condition @p Condition in
+/// the @p Domain.
///
/// This will fill @p ConditionSets with the conditions under which control
/// 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(Scop &S, Value *Condition, 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);
-
- assert(isa<BranchInst>(TI) && "Terminator was neither branch nor switch.");
-
- if (TI->getNumSuccessors() == 1) {
- ConditionSets.push_back(isl_set_copy(Domain));
- return;
- }
-
- Value *Condition = getConditionFromTerminator(TI);
- assert(Condition && "No condition for Terminator");
-
isl_set *ConsequenceCondSet = nullptr;
if (auto *CCond = dyn_cast<ConstantInt>(Condition)) {
if (CCond->isZero())
ConsequenceCondSet = isl_set_empty(isl_set_get_space(Domain));
else
ConsequenceCondSet = isl_set_universe(isl_set_get_space(Domain));
+ } else if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(Condition)) {
+ 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);
+
+ isl_set_free(ConditionSets.pop_back_val());
+ isl_set *ConsCondPart0 = ConditionSets.pop_back_val();
+ isl_set_free(ConditionSets.pop_back_val());
+ isl_set *ConsCondPart1 = ConditionSets.pop_back_val();
+
+ if (Opcode == Instruction::And)
+ ConsequenceCondSet = isl_set_intersect(ConsCondPart0, ConsCondPart1);
+ else
+ ConsequenceCondSet = isl_set_union(ConsCondPart0, ConsCondPart1);
} else {
auto *ICond = dyn_cast<ICmpInst>(Condition);
assert(ICond &&
@@ -1051,6 +1055,32 @@ buildConditionSets(Scop &S, TerminatorInst *TI, Loop *L,
isl_set_intersect(AlternativeCondSet, isl_set_copy(Domain))));
}
+/// @brief Build the conditions sets for the terminator @p TI in the @p Domain.
+///
+/// This will fill @p ConditionSets with the conditions under which control
+/// 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,
+ __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);
+
+ assert(isa<BranchInst>(TI) && "Terminator was neither branch nor switch.");
+
+ if (TI->getNumSuccessors() == 1) {
+ ConditionSets.push_back(isl_set_copy(Domain));
+ return;
+ }
+
+ Value *Condition = getConditionFromTerminator(TI);
+ assert(Condition && "No condition for Terminator");
+
+ return buildConditionSets(S, Condition, TI, L, Domain, ConditionSets);
+}
+
void ScopStmt::buildDomain() {
isl_id *Id;
OpenPOWER on IntegriCloud