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


On 10/19/07, Andrew Haley <aph-gcc@littlepinkcloud.com> wrote:
> 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.

In fact I had a qsort implementation which did that and used the
following patch to fix up the issue:
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c (revision 1433)
+++ tree-ssa-operands.c (revision 1434)
@@ -175,6 +175,8 @@ operand_build_cmp (const void *p, const
   tree e1 = *((const tree *)p);
   tree e2 = *((const tree *)q);
   unsigned int u1,u2;
+  if (p == q)
+    return 0;

   u1 = get_name_decl (e1);
   u2 = get_name_decl (e2);


I did not add a comment to the function but that is because I added it
to the commit message.

The first issue is that qsort can call the compare function with the same
pointers, take that into account in operand_build_cmp.


Thanks,
Andrew Pinski


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