Hi, in the following testcases we should be able to disambiguate accesses: struct a { int ia; struct b { int ib; struct c { int ic; } c[2]; } b[5]; } a; test (int i,int j) { struct c *bptr=&a.b[i].c[1]; struct c *cptr=&a.b[j].c[2]; bptr->ic=1; cptr->ic=2; return bptr->ic; } and struct data {int data,data2;} *ptr; int *ptr2; struct a {struct data a;}; struct b {struct a a[10];} *bptr; test (int i) { struct a *aptr = &bptr->a[i]; aptr->a.data=0; ptr->data2=1; return aptr->a.data; } (this one works with clang but does not because of way we fold address calculations) and typedef int (*fnptr) (); __attribute__ ((used)) int *a,**aptr=&a; __attribute__ ((used)) struct b {int *a;} *bptr,b; static void inline_me_late (int argc) { if (argc == -1) *bptr = b; } int main (int argc) { a = 0; inline_me_late (argc); if (!__builtin_constant_p (a == 0)) __builtin_abort (); return 0; } compiled with -O3 -flto -fno-early-inlining
Another testcase. Here we should disambiguate both cases while we do only second struct a {int a1; int a2;}; struct b:a {}; struct b bvar,*bptr2; int test(void) { struct a *bptr = &bvar; bptr->a2=0; bptr2->a1=1; return bptr->a2; } int test2(void) { struct b *bptr = &bvar; bptr->a2=0; bptr2->a1=1; return bptr->a2; }
Author: hubicka Date: Thu Jun 13 15:00:41 2019 New Revision: 272247 URL: https://gcc.gnu.org/viewcvs?rev=272247&root=gcc&view=rev Log: PR tree-optimize/90869 * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Watch for view converts in MEM_REF referencing decl rather than view converts from decl type to MEM_REF type. * g++.dg/tree-ssa/alias-access-path-1.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/alias-access-path-1.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-alias.c
@Honza: Can we close this?
No, we disambiguate the first testcase but not the others.