This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][middle-end] Make qsort in tree-ssa-sccvn.c stable.
- From: Rafael Espindola <espindola at google dot com>
- To: Doug Kwan (éæå) <dougkwan at google dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 May 2009 10:25:49 +0100
- Subject: Re: [PATCH][middle-end] Make qsort in tree-ssa-sccvn.c stable.
- References: <498552560905111859p6b0aaa21sb98953e57d950dfd@mail.gmail.com>
> + Â/* Make qsort stable by doing addition comparisons. */
s/addition/additional/ ?
> +
> + Âver_a = SSA_NAME_VERSION (opa);
> + Âver_b = SSA_NAME_VERSION (opb);
> + Âif (ver_a < ver_b)
> + Â Âreturn -1;
> + Âelse if (ver_a > ver_b)
> + Â Âreturn 1;
> + Âelse
> + Â Âreturn 0;
> +}
If this function returns 0 then the sort not stable, just not as
unstable as before. If you are sure this cannot happen, you should
replace "return 0" with gcc_unreachable(). If not, please note in a
comment that the sort is not completely stable.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047