This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Operand Scan times


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]