If the sign of exit condition and split condition does not match
then do not split loop index.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 9a5920c..8c54ce3 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -1437,7 +1437,12 @@
     if (ICMP->getPredicate() == ICmpInst::ICMP_EQ)
       return false;
   }
-  
+
+  // If the predicate sign does not match then skip.
+  ICmpInst *CI = dyn_cast<ICmpInst>(SD.SplitCondition);
+  if (CI && (ExitCondition->isSignedPredicate() != CI->isSignedPredicate()))
+    return false;
+
   BasicBlock *SplitCondBlock = SD.SplitCondition->getParent();
   
   // Unable to handle triangle loops at the moment.