OSDN Git Service

* ira-color.c (SORTGT): New macro, helper for qsort callbacks.
authorhainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Sep 2010 07:22:33 +0000 (07:22 +0000)
committerhainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Sep 2010 07:22:33 +0000 (07:22 +0000)
        (allocno_priority_compare_func): Use it instead of a straight
        difference computation over priorities.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163760 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ira-color.c

index 6a551c2..04afe92 100644 (file)
@@ -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.
        (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
index 8360735..7f02bcf 100644 (file)
@@ -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)
+
 \f
 
 /* 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.  */