public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Tree aliasing
@ 2009-08-04  3:55 Andrew Pinski
  2009-08-04  8:52 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2009-08-04  3:55 UTC (permalink / raw)
  To: GCC Mailing List, Richard Guenther

I was improving tree aliasing for pointers by adding support a+1 and a
not aliasing.  But I ran into a bug in the aliasing where:
  /* If both references are through the same type, they do not alias
     if the accesses do not overlap.  This does extra disambiguation
     for mixed/pointer accesses but requires strict aliasing.  */
  if (same_type_for_tbaa (TREE_TYPE (TREE_TYPE (ptr1)),
                          TREE_TYPE (TREE_TYPE (ptr2))) == 1)
    return ranges_overlap_p (offset1, max_size1, offset2, max_size2);

Would return false even.  I can't see how this can be true if one
pointer is defined as an offset as the other and the offset1 or
offset2 are non zero.

Can someone explain why this is true?

Even nonaliasing_component_refs_p looks to have the same issue if the
types are the same, they could be an extra offset from each other,
even though the compiler cannot figure that out.  I am thinking of
when storing the pointer in an array and then accessing that pointer.

gcc.dg/20030324-1.c is the testcase where I am running into this bug too.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Tree aliasing
  2009-08-04  3:55 Tree aliasing Andrew Pinski
@ 2009-08-04  8:52 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2009-08-04  8:52 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Mailing List

On Tue, Aug 4, 2009 at 4:25 AM, Andrew Pinski<pinskia@gmail.com> wrote:
> I was improving tree aliasing for pointers by adding support a+1 and a
> not aliasing.  But I ran into a bug in the aliasing where:
>  /* If both references are through the same type, they do not alias
>     if the accesses do not overlap.  This does extra disambiguation
>     for mixed/pointer accesses but requires strict aliasing.  */
>  if (same_type_for_tbaa (TREE_TYPE (TREE_TYPE (ptr1)),
>                          TREE_TYPE (TREE_TYPE (ptr2))) == 1)
>    return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
>
> Would return false even.  I can't see how this can be true if one
> pointer is defined as an offset as the other and the offset1 or
> offset2 are non zero.
>
> Can someone explain why this is true?

This is true because if you have two pointers pointing to the indentical
type T then with strict-aliasing you either have a full overlap
(ptr1 == ptr2) or no overlap.  I can see one mistake here in that
the offsets (I need to think about the max-sizes) need to be modulo
the size of the pointed-to type, but
other than that it's ok.  A fix for that is appreciated (together with
a testcase of course).

Richard.

> Even nonaliasing_component_refs_p looks to have the same issue if the
> types are the same, they could be an extra offset from each other,
> even though the compiler cannot figure that out.  I am thinking of
> when storing the pointer in an array and then accessing that pointer.
>
> gcc.dg/20030324-1.c is the testcase where I am running into this bug too.
>
> Thanks,
> Andrew Pinski
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-04  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04  3:55 Tree aliasing Andrew Pinski
2009-08-04  8:52 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).