Swap exit condition operands if it works.
authorDevang Patel <dpatel@apple.com>
Mon, 10 Sep 2007 23:34:06 +0000 (23:34 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 10 Sep 2007 23:34:06 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41817 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopIndexSplit.cpp

index 3a046655d5efb1817a1f73052226f8a81bb7f7c0..0f55a9100c3ae57a7b1b32265ae1ea10ab15a99f 100644 (file)
@@ -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;