make qsort predicate more conformant by returning 0 for equal values.
authorChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 04:52:41 +0000 (04:52 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 04:52:41 +0000 (04:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121838 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index bbdde4b51f49501f23ce7fb4e9e874663fc2b10a..23a3a25056a28d452a7c7ed0754433acb987c0df 100644 (file)
@@ -592,7 +592,11 @@ namespace {
 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()) ? 1 : -1;
+  if (LHS->getValue().ult(RHS->getValue()))
+    return 1;
+  if (LHS->getValue() == RHS->getValue())
+    return 0;
+  return -1;
 }
 
 /// FoldValueComparisonIntoPredecessors - The specified terminator is a value