aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 3a04665..0f55a91 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -328,14 +328,24 @@ void LoopIndexSplit::findLoopConditionals() {
if (!CI)
return;
- // FIXME
+ // FIXME
+ if (CI->getPredicate() == ICmpInst::ICMP_EQ
+ || CI->getPredicate() == ICmpInst::ICMP_NE)
+ return;
+
if (CI->getPredicate() == ICmpInst::ICMP_SGT
|| CI->getPredicate() == ICmpInst::ICMP_UGT
|| CI->getPredicate() == ICmpInst::ICMP_SGE
- || CI->getPredicate() == ICmpInst::ICMP_UGE
- || CI->getPredicate() == ICmpInst::ICMP_EQ
- || CI->getPredicate() == ICmpInst::ICMP_NE)
- return;
+ || CI->getPredicate() == ICmpInst::ICMP_UGE) {
+
+ BasicBlock *FirstSuccessor = BR->getSuccessor(0);
+ // splitLoop() is expecting LT/LE as exit condition predicate.
+ // Swap operands here if possible to meet this requirement.
+ if (!L->contains(FirstSuccessor))
+ CI->swapOperands();
+ else
+ return;
+ }
ExitCondition = CI;