aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@gcc.gnu.org>2010-09-02 07:22:33 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2010-09-02 07:22:33 +0000
commit71af27d2fb311e0231367467d780193bc1b03762 (patch)
tree4a3c26d34c537a2a001d76836e75e512b848a275 /gcc
parente10909ceaf93ae366ee3c70500854a132c088afb (diff)
downloadgcc-71af27d2fb311e0231367467d780193bc1b03762.zip
gcc-71af27d2fb311e0231367467d780193bc1b03762.tar.gz
gcc-71af27d2fb311e0231367467d780193bc1b03762.tar.bz2
ira-color.c (SORTGT): New macro, helper for qsort callbacks.
* ira-color.c (SORTGT): New macro, helper for qsort callbacks. (allocno_priority_compare_func): Use it instead of a straight difference computation over priorities. From-SVN: r163760
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/ira-color.c10
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6a551c2..04afe92 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-09-02 Olivier Hainque <hainque@adacore.com>
+
+ * ira-color.c (SORTGT): New macro, helper for qsort callbacks.
+ (allocno_priority_compare_func): Use it instead of a straight
+ difference computation over priorities.
+
2010-09-02 Andi Kleen <ak@linux.intel.com>
* opts.c (common_handle_option): Fix OPT_fwhopr/fwhopr_ handling.
@@ -170,6 +176,7 @@
(scev_probably_wraps_p): Adjust.
* tree-ssa-loop.c (tree_ssa_loop_bounds): Likewise.
+>>>>>>> .r163759
2010-09-01 Nick Clifton <nickc@redhat.com>
* config/stormy16/stormy16.c: Use REG_P, MEM_P and CONST_INT_P
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index 8360735..7f02bcf 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -83,6 +83,12 @@ static alloc_pool splay_tree_node_pool;
more costly although simpler. */
static VEC(ira_allocno_t,heap) *removed_splay_allocno_vec;
+/* Helper for qsort comparison callbacks - return a positive integer if
+ X > Y, or a negative value otherwise. Use a conditional expression
+ instead of a difference computation to insulate from possible overflow
+ issues, e.g. X - Y < 0 for some X > 0 and Y < 0. */
+#define SORTGT(x,y) (((x) > (y)) ? 1 : -1)
+
/* This page contains functions used to find conflicts using allocno
@@ -1858,8 +1864,8 @@ allocno_priority_compare_func (const void *v1p, const void *v2p)
pri1 = allocno_priorities[ALLOCNO_NUM (a1)];
pri2 = allocno_priorities[ALLOCNO_NUM (a2)];
- if (pri2 - pri1)
- return pri2 - pri1;
+ if (pri2 != pri1)
+ return SORTGT (pri2, pri1);
/* If regs are equally good, sort by allocnos, so that the results of
qsort leave nothing to chance. */