Fix PR 33870

Richard Guenther rguenther@suse.de
Thu Nov 15 15:47:00 GMT 2007


On Thu, 15 Nov 2007, Richard Guenther wrote:

> On Wed, 14 Nov 2007, Diego Novillo wrote:
> 
> > Richard Guenther wrote:
> > 
> > > Bootstrap and regtest on x86_64-unknown-linux-gnu in progress, I intend
> > > to commit this if that (as expected) finishes successfully.
> > 
> > No, let me study this first.
> 
> We can also add one additional optimization and sanity check.  In
> add_virtual_operand instead of dispatching to add_vars_for_offset for
> every SFT in the NMT just do so for those that have
> SFT_BASE_FOR_COMPONENTS_P set.  All others can (should) be only directly
> dereferenced which means offset has to be zero.  If not, we should
> visit them during one of the add_vars_for_offset calls.  This avoids
> redundant calls to append_vuse/vdef (so it's merely a compile-time
> improvement):
> 
>          /* For SFTs we have to consider all subvariables of the parent 
> var
>              if it is a potential points-to location.  */
>           if (TREE_CODE (al) == STRUCT_FIELD_TAG
>               && TREE_CODE (var) == NAME_MEMORY_TAG)
>             {
>               if (SFT_BASE_FOR_COMPONENTS_P (al))
>                 none_added &= !add_vars_for_offset (al, offset, size,
>                                                     flags & opf_def);
>               else if (offset == 0)
>                 {
>                   /* If this is a SFT that cannot be used as a base for
>                      component references, we only need to consider them
>                      if offset is zero.  Otherwise if it is aliased via
>                      a component ref we will visit it during processing
>                      of a SFT_BASE_FOR_COMPONENTS_P pointed-to SFT.
>                      In this case just add this SFT as a possible direct
>                      dereference target.  */
>                   if (flags & opf_def)
>                     append_vdef (al);
>                   else
>                     append_vuse (al);
>                   none_added = false;
>                 }
> 
> I guess we don't want to do this as part of the initial patch, but I'll
> check the compile-time effects if the above works out.

Ok, that doesn't work.  As we have cases where we can have sub-references
on an SFT (notably in the case where we glob fields into a single
SFT as we do for arrays with more than 4 elements), the offset of the
access may be bigger than zero.  Even if we only can reach the SFT itself
we cannot avoid the append_vdef/vuse in any case, so the possible speed
difference should be a wash.

That is we can do

          if (TREE_CODE (al) == STRUCT_FIELD_TAG
              && TREE_CODE (var) == NAME_MEMORY_TAG)
            {
              if (SFT_BASE_FOR_COMPONENTS_P (al))
                none_added &= !add_vars_for_offset (al, offset, size,
                                                    flags & opf_def);
              else
                {
                  /* If this is a SFT that cannot be used as a base for
                     component references, we only need to consider them
                     if offset is zero.  Otherwise if it is aliased via
                     a component ref we will visit it during processing
                     of a SFT_BASE_FOR_COMPONENTS_P pointed-to SFT.
                     In this case just add this SFT as a possible direct
                     dereference target.  */
                  if (flags & opf_def)
                    append_vdef (al);
                  else
                    append_vuse (al);
                  none_added = false;
                }

Richard.



More information about the Gcc-patches mailing list