From 71af27d2fb311e0231367467d780193bc1b03762 Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Thu, 2 Sep 2010 07:22:33 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 7 +++++++ gcc/ira-color.c | 10 ++++++++-- 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 + + * 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 * 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 * 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. */ -- 2.7.4