This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Operand Scan times
- From: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: Rask Ingemann Lambertsen <rask at sygehus dot dk>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 19 Oct 2007 18:46:03 +0100
- Subject: Re: Operand Scan times
- References: <1128366775.3080.7.camel@pain> <20071019171348.GY25795@sygehus.dk> <4718EC7E.8020203@redhat.com>
Andrew MacLeod writes:
> Rask Ingemann Lambertsen wrote:
>
> >> + /* Comparison function for qsort used in operand_build_sort_virtual. */
> >>
> >> ! static int
> >> ! operand_build_cmp (const void *p, const void *q)
> >> {
> >> ! tree e1 = *((const tree *)p);
> >> ! tree e2 = *((const tree *)q);
> >> ! unsigned int u1,u2;
> >>
> >> + u1 = get_name_decl (e1);
> >> + u2 = get_name_decl (e2);
> >> +
> >> + /* We want to sort in ascending order. They can never be equal. */
> >> #ifdef ENABLE_CHECKING
> >> ! gcc_assert (u1 != u2);
> >> #endif
> >> ! return (u1 > u2 ? 1 : -1);
> >> }
> >>
> >
> > Where does it say that qsort() isn't allowed to to pass p == q or pass a
> > pointer to a copy of *p as q (*tmp = *p; operand_build_cmp (p, tmp);)?
> It doesn't say that anywhere about qsort(). Processing of virtual
> operands should already have removed all duplicates, so the assert is to
> verify that the same name should never be in the list more than once at
> this point, thus they can never be equal.
I think you're missing the point, Andrew. A qsort() implementation
might pass a pointer to the same array element in p and q during
partitioning. In that case, u1 == u2. Your assert is wrong.
Andrew.