view gcc/testsuite/gcc.dg/tree-ssa/alias-29.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
/* { dg-add-options bind_pic_locally } */

union X {
    int i;
    void *p;
};
void bar (int);

int * __attribute__((noinline,noclone))
baz (int *p) { return p; }

void foo (union X *x)
{
  struct Y { int i; } ystruct = {};
  ystruct.i = * baz (&ystruct.i);
  bar (x->i);
}

/* DSE and then DCE should be able to remove all uses of ystruct.
   Formerly the union access for the parameter to bar let 'anything'
   escape which made the call to bar possibly use ystruct and thus
   prevent the store to ystruct.i from being eliminated.  The call to
   baz makes sure that ystruct has its address taken.  */

/* { dg-final { scan-tree-dump-not "ystruct" "optimized" } } */