[PATCH] Remove special-casing of PTR_IS_REF_ALL pointers from alias analysis

Richard Guenther rguenther@suse.de
Thu May 1 13:23:00 GMT 2008


On Thu, 1 May 2008, Richard Kenner wrote:

> >  T *p = &a;
> >  p->b = x;
> > 
> > which is valid, the used alias set is _always_ that of the base object
> > *p, which is the structures alias set, for the purpose of conflict
> > decision.
> 
> Well, I can't speak for the tree-level aliasing, but at the RTL level,
> the alias set for p->b is that of the type of "b" normally and of *p
> if DECL_NONADDRESSABLE_P.

The RTL level uses get_alias_set on the RTX mem_expr and so will use
the alias set of *p, not of b (which would be pessimizing a trivially
easy to get right case).  Remember that for example for

struct X { int x; } x; struct Y { int y; } y;

x.x and y.y don't conflict, but they would if you'd use the alias set
for int.  x.x and int *p; *p still conflict, as int is a subset of
X aliases.

> 
> >  2) Why we need to record the parents alias set at all.  To cite
> >     tree.h:
> > 
> > struct tree_struct_field_tag GTY(())
> > {
> > ...
> >   /* Alias set for a DECL_NONADDRESSABLE_P field.  Otherwise -1.  */
> >   alias_set_type alias_set;
> > };
> 
> I have no idea what that is.

This is the alias set used for fields that have DECL_NONADDRESSABLE_P set.
Probably because you can't get at the parent FIELD_DECL from a FIELD_DECL
itself.  8 bytes wasted IMHO.

> > But as said, it is up to the frontends to avoid addressing non-addressable
> > things.
> 
> Of course!  But knowing that's going to happen is very useful
> information for aliasing analysis.  Perhaps you're saying that there's no
> way for the tree level analysis to use that information, but there
> *certainly* is a way for the RTL level to do and it always has.

The tree level always uses this information.  The only case that would
go wrong is if you _did_ have an address to the non-addressable x.b,
where then T *p = &x.b; *p = x; would use the "wrong" (imprecise)
alias set.  But if this doesn't happen then the tree level is
automagically using the more precise alias set regardless of
the field being addressable or not.  I wonder why and if the RTL
level really get's this trivially optimization wrong ...

Richard.



More information about the Gcc-patches mailing list