Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. Fixes PR 8780.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121705 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 71d9ef8..9ca1079 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -598,7 +598,7 @@
 static int ConstantIntSortPredicate(const void *P1, const void *P2) {
   const ConstantInt *LHS = *(const ConstantInt**)P1;
   const ConstantInt *RHS = *(const ConstantInt**)P2;
-  return LHS->getValue().ult(RHS->getValue());
+  return LHS->getValue().ult(RHS->getValue()) ? 1 : -1;
 }
 
 /// FoldValueComparisonIntoPredecessors - The specified terminator is a value