diff options
| author | nickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-31 14:28:38 +0000 |
|---|---|---|
| committer | nickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-31 14:28:38 +0000 |
| commit | 6a0a4c31e872d3ef97ef084da9c0ead37248bc30 (patch) | |
| tree | 186057dc0dca9f422aab0bbbc925c792aee79361 | |
| parent | c171b8cfaaa9c0f84227d8d9d77cf01a3809df4d (diff) | |
| download | ppe42-gcc-6a0a4c31e872d3ef97ef084da9c0ead37248bc30.tar.gz ppe42-gcc-6a0a4c31e872d3ef97ef084da9c0ead37248bc30.zip | |
* tree-ssa-coalesce.c (compare_pairs): Use the elements as secondary keys
in order to obtain a stable sort.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127993 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/tree-ssa-coalesce.c | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 50832cf78bf..e7d598a7a7f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2007-08-31 Nick Clifton <nickc@redhat.com> + * tree-ssa-coalesce.c (compare_pairs): Use the elements as + secondary keys in order to obtain a stable sort. + +2007-08-31 Nick Clifton <nickc@redhat.com> + PR target/33132 * config/m32r/constraints.md: Add W constraint for integer zero. * config/m32r/m32r.md (get_pc): Use W and i constraints. diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 1b63635881b..ef1ebcab4a9 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -314,8 +314,22 @@ add_coalesce (coalesce_list_p cl, int p1, int p2, static int compare_pairs (const void *p1, const void *p2) { - return (*(const_coalesce_pair_p const*)p1)->cost - - (*(const_coalesce_pair_p const*)p2)->cost; + const_coalesce_pair_p const * pp1 = p1; + const_coalesce_pair_p const * pp2 = p2; + int result; + + result = (* pp2)->cost - (* pp1)->cost; + /* Since qsort does not guarantee stability we use the elements + as a secondary key. This provides us with independence from + the host's implementation of the sorting algorithm. */ + if (result == 0) + { + result = (* pp2)->first_element - (* pp1)->first_element; + if (result == 0) + result = (* pp2)->second_element - (* pp1)->second_element; + } + + return result; } |

