This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: GCC 4.2.1: Stabalizing coalesce_list's qsort
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Nick Clifton" <nickc at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 22 Aug 2007 13:40:22 +0200
- Subject: Re: RFA: GCC 4.2.1: Stabalizing coalesce_list's qsort
- References: <m3sl6ev6iq.fsf@redhat.com>
On 8/20/07, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
> I am not sure if this patch counts as fixing a regression, but I am
> going to submit it anyway.
>
> The problem is that gcc appears to rely upon the
> sort_coalesce_list() function in tree-ssa-live.c performing a stable
> sort of the coalesce list. (ie one where items with the same key
> value retain the same relative ordering after the sort).
> Unfortunately the C library function qsort() does not guarantee
> this, and while it just so happens that under Linux the qsort is
> stable, under other operating systems and execution environments
> this is not the case. (The problem was actually detected when
> running gcc under Cygwin).
>
> The proposed patch fixes the problem by extending the comparison
> function passed to the invocation of qsort so that when two
> partition pairs do have the same cost they are compared based on
> their location in the partition arrays. This has the effect of
> stabalizing the sort, allowing the Cygwin hosted toolchain to behave
> in exactly the same way as the Linux hosted toolchain, and so
> preventing Cygwin-only code generation bugs.
>
> Is this patch suitable for application to the 4.2 branch ?
No, but for trunk if you bootstrapped/tested this. That is, this patch
is ok for mainline if you did.
Thanks,
Richard.
> Cheers
> Nick
>
> gcc/ChangeLog
> 2007-08-20 Nick Clifton <nickc@redhat.com>
>
> * tree-ssa-live.c (compare_pairs): Stabalize the comparison by
> checking the partition indicies if the costs are the same.