From 14991199757d4f1cb9fb1bed7d650918e2643f98 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 15 Dec 2010 04:52:41 +0000 Subject: [PATCH] make qsort predicate more conformant by returning 0 for equal values. llvm-svn: 121838 --- lib/Transforms/Utils/SimplifyCFG.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index bbdde4b51f4..23a3a25056a 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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