On Tue, 14 Apr 2020, Jan Hubicka wrote:

> > 
> > But we're using it in indirect_ref_may_alias_decl_p as
> > 
> >       /* If second reference is view-converted, give up now.  */
> >       if (same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (ptrtype2)) != 
> > 1)
> >         return true;
> > 
> > and clearly if TREE_TYPE (ptrtype2) is void * while TREE_TYPE (dbase2)
> > is T * we've "view-converted" things.
> > 
> > Not sure what the consequence is when we fall through here since those
> > checks may be redundant now(?)  But given we're late for GCC 10 I'd
> > rather be safe than sorry ;)
> 
> I think this check is about part of access path missing (i.e. we have
> access path like a.b.c.d.e.f while mem-ref took part of it away
> so we have a.b.c...f).
> So here c and f should not be both pointers.
> > 
> > > For ICF checking we need to be more careful anyway (in particular we do
> > > not want all those -1s on arrays), so I would worry about that next
> > > stage1.
> > > 
> > > With 1 we will probably save some work since the code will not continue
> > > looking for must aliases.
> > 
> > I think we have still quite some cleanup to do for the path-based
> > disambiguations.
> 
> Yep, one issue at a time....

I've now pushed the last version, let's improve things in GCC 11.

Richard.

> Honza
> > 
> > Richard.
> > 
> > > Honza
> > > 
> > > > 
> > > > So, like the following.
> > > > 
> > > > Richard.
> > > > 
> > > > 
> > > > middle-end/94539 - void * aliases every other pointer
> > > > 
> > > > This makes same_type_for_tbaa_p conservative in the same way
> > > > get_alias_set is about void * which we allow to alias all other
> > > > pointers.
> > > > 
> > > > 2020-04-14  Richard Biener  <rguent...@suse.de>
> > > > 
> > > >         PR middle-end/94539
> > > >         * tree-ssa-alias.c (same_type_for_tbaa): Defer to
> > > >         alias_sets_conflict_p for pointers.
> > > > 
> > > >         * gcc.dg/alias-14.c: Make dg-do run.
> > > > ---
> > > >  gcc/testsuite/gcc.dg/alias-14.c |  2 +-
> > > >  gcc/tree-ssa-alias.c            | 11 ++++++++++-
> > > >  2 files changed, 11 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/gcc/testsuite/gcc.dg/alias-14.c 
> > > > b/gcc/testsuite/gcc.dg/alias-14.c
> > > > index 1ca1c09d5e3..24f0d1c1168 100644
> > > > --- a/gcc/testsuite/gcc.dg/alias-14.c
> > > > +++ b/gcc/testsuite/gcc.dg/alias-14.c
> > > > @@ -1,4 +1,4 @@
> > > > -/* { dg-do compile } */
> > > > +/* { dg-do run } */
> > > >  /* { dg-options "-O2" } */
> > > >  #include <stddef.h>
> > > >  void *a;
> > > > diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> > > > index df9ba0de0d6..ede4f198342 100644
> > > > --- a/gcc/tree-ssa-alias.c
> > > > +++ b/gcc/tree-ssa-alias.c
> > > > @@ -839,7 +839,16 @@ same_type_for_tbaa (tree type1, tree type2)
> > > >       would mean that conversions between them are useless, whereas 
> > > > they are
> > > >       not (e.g. type and subtypes can have different modes).  So, in 
> > > > the end,
> > > >       they are only guaranteed to have the same alias set.  */
> > > > -  if (get_alias_set (type1) == get_alias_set (type2))
> > > > +  alias_set_type set1 = get_alias_set (type1);
> > > > +  alias_set_type set2 = get_alias_set (type2);
> > > > +  if (set1 == set2)
> > > > +    return -1;
> > > > +
> > > > +  /* Pointers to void are considered compatible with all other 
> > > > pointers,
> > > > +     so for two pointers see what the alias set resolution thinks.  */
> > > > +  if (POINTER_TYPE_P (type1)
> > > > +      && POINTER_TYPE_P (type2)
> > > > +      && alias_sets_conflict_p (set1, set2))
> > > >      return -1;
> > > >  
> > > >    /* The types are known to be not equal.  */
> > > > -- 
> > > > 2.13.7
> > > > 
> > > 
> > 
> > -- 
> > Richard Biener <rguent...@suse.de>
> > SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
> > Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Reply via email to