This is the mail archive of the 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: PATCH [mainline] speed up comparing enums declared in multiple translation units

On Mar 9, 2004, at 12:57 PM, Andrew Pinski wrote:

On Mar 9, 2004, at 12:40, Fariborz Jahanian wrote:

On Mar 9, 2004, at 12:27 PM, Andrew Pinski wrote:

Why are you getting rid of the code which I put in there to speed it up in the first place?
"Speed up the case where the type values are in the same order".

What code? I am working off the tree-ssa branch. This patch works regardless of any
assumption of type values.

This part:
! /* Speed up the case where the type values are in the same order. */
! tree tv1 = TYPE_VALUES (t1);
! tree tv2 = TYPE_VALUES (t2);
! if (tv1 == tv2)
! return 1;
! for (;tv1 && tv2; tv1 = TREE_CHAIN (tv2), tv2 = TREE_CHAIN (tv2))
! {
! if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
! break;
! if (simple_cst_equal (TREE_VALUE (tv1), TREE_VALUE (tv2)) != 1)
! return 0;
! }
! if (tv1 == NULL_TREE && tv2 == NULL_TREE)
! return 1;
! if (tv1 == NULL_TREE || tv2 == NULL_TREE)
! return 0;

The whole point of this patch was to change the algorithm to be O(n) instead of O(n*m).
Since the common case is still that the type values are in the same order for both
translational units this really should be kept. Also it does not have transverse the
second linked list twice.

All mallocs are freed, after the structs in which enums are used are themselves compared. I don't
see n is being that large.

Yes you free them after comparing them but that just takes more as you still need to do the
above enum comparision for each enum more than once.

Try it right now without your patch and see how fast it is, it should not take more than an
hour as it takes on my machine.

I had something like this before I did my new patch. It took hour and one-half on my 2G G5 machine.

Note that saving comes not in speeding up type comparison, but avoid repeat comparisons. This is
at least the case in mesa. With my patch, mesa built in 13 minutes with a gcc built with -O0 -g.

- fariborz

Thanks, Andrew Pinski

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