1 /* { dg-do run } */
2 /* { dg-require-alias "" } */
3 /* { dg-options "-O -fdump-tree-fre1" } */
4 
5 extern void abort (void);
6 
7 struct X { int a[128]; };
8 static const struct X a = { 0, 1, 2, 3 };
9 /* Prevent gimplify_modify_expr_rhs / gimplify_init_constructor from
10    expanding the aggregate copy below inline.  */
11 static const struct X A __attribute__((alias("a")));
12 struct X *q;
13 int __attribute__((noinline))
foo()14 foo ()
15 {
16   struct X b = A;
17   int *p = &b.a[2];
18   /* Prevent SRA from decomposing b.  */
19   q = &b;
20   return *p;
21 }
22 
main()23 int main()
24 {
25   if (foo() != 2)
26     abort ();
27   return 0;
28 }
29 
30 /* Verify the aggregate copy we want to look through is still in place.  */
31 /* { dg-final { scan-tree-dump "b = A;" "fre1" } } */
32 /* Verify we have propagated the element read all the way to the return.  */
33 /* { dg-final { scan-tree-dump "return 2" "fre1" } } */
34