https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90869

            Bug ID: 90869
           Summary: Non-disambiguated memory accesses
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

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

Reply via email to