On Tue, 16 Apr 2019, Michael Matz wrote:

> Hi,
> 
> On Tue, 16 Apr 2019, Richard Biener wrote:
> 
> > Comments?
> 
> I was quickly testing also with some early-outs but didn't get conclusive 
> performance results (but really only superficial testing) so I'm not 
> proposing it, like so:
> 
> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> index 7045284..33f56f9 100644
> --- a/gcc/cp/typeck.c
> +++ b/gcc/cp/typeck.c
> @@ -1508,6 +1508,10 @@ same_type_ignoring_top_level_qualifiers_p (tree 
>    if (type1 == error_mark_node || type2 == error_mark_node)
>      return false;
>  
> +  if (type1 == type2)
> +    return true;

This one reduces the number of get_qualified_type calls
by about 10%.  Probably worth doing.

Another smallish improvement is using strip_top_quals which
does nothing for ARRAY_TYPE.

Btw, the new get_qualified_type shows (with the above patch applied)

   if (TYPE_QUALS (type) == type_quals)
     return type; // 0.3% hit

   tree mv = TYPE_MAIN_VARIANT (type);
   if (check_qualified_type (mv, type, type_quals))
     return mv; // 43.8% hit

for the C++ FE the LRU cache effectively moves the unqualified
variants first in the variant list.  Since we always first
build the unqualified variants before the qualified ones
the unqualified ones tend to be at the end of the list.  That's
clearly bad for the C++ pattern of repeatedly looking up the
unqualified type variant from a type.  Of course a direct
shortcut would be much cheaper here (but it obviously isn't
the main variant due to TYPE_NAME differences).

So do you think the change to get_qualified_type is OK?  Or
do we absolutely want to avoid changing the variant list from
a function like this?

Thanks,
Richard.

Reply via email to