aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopIndexSplit.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-09-10 23:34:06 +0000
committerDevang Patel <dpatel@apple.com>2007-09-10 23:34:06 +0000
commit0c0f7c935bc4c6de74bd4025ceca7278e128f48d (patch)
treee3e158048a04647bde88d2d89de4edc2b01f6391 /lib/Transforms/Scalar/LoopIndexSplit.cpp
parent569f7371d6d7ceb8d8c48625e767f4b6d21cd219 (diff)
Swap exit condition operands if it works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-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 3a046655d5..0f55a9100c 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;