1 /* PR middle-end/22141 */
2 
3 extern void abort (void);
4 
5 struct S
6 {
7   struct T
8     {
9       char a;
10       char b;
11       char c;
12       char d;
13     } t;
14 } u __attribute__((aligned));
15 
16 struct U
17 {
18   struct S s[4];
19 };
20 
21 void __attribute__((noinline))
c1(struct T * p)22 c1 (struct T *p)
23 {
24   if (p->a != 1 || p->b != 2 || p->c != 3 || p->d != 4)
25     abort ();
26   __builtin_memset (p, 0xaa, sizeof (*p));
27 }
28 
29 void __attribute__((noinline))
c2(struct S * p)30 c2 (struct S *p)
31 {
32   c1 (&p->t);
33 }
34 
35 void __attribute__((noinline))
c3(struct U * p)36 c3 (struct U *p)
37 {
38   c2 (&p->s[2]);
39 }
40 
41 void __attribute__((noinline))
f1(void)42 f1 (void)
43 {
44   u = (struct S) { { 1, 2, 3, 4 } };
45 }
46 
47 void __attribute__((noinline))
f2(void)48 f2 (void)
49 {
50   u.t.a = 1;
51   u.t.b = 2;
52   u.t.c = 3;
53   u.t.d = 4;
54 }
55 
56 void __attribute__((noinline))
f3(void)57 f3 (void)
58 {
59   u.t.d = 4;
60   u.t.b = 2;
61   u.t.a = 1;
62   u.t.c = 3;
63 }
64 
65 void __attribute__((noinline))
f4(void)66 f4 (void)
67 {
68   struct S v __attribute__((aligned));
69   v.t.a = 1;
70   v.t.b = 2;
71   v.t.c = 3;
72   v.t.d = 4;
73   c2 (&v);
74 }
75 
76 void __attribute__((noinline))
f5(struct S * p)77 f5 (struct S *p)
78 {
79   p->t.a = 1;
80   p->t.c = 3;
81   p->t.d = 4;
82   p->t.b = 2;
83 }
84 
85 void __attribute__((noinline))
f6(void)86 f6 (void)
87 {
88   struct U v __attribute__((aligned));
89   v.s[2].t.a = 1;
90   v.s[2].t.b = 2;
91   v.s[2].t.c = 3;
92   v.s[2].t.d = 4;
93   c3 (&v);
94 }
95 
96 void __attribute__((noinline))
f7(struct U * p)97 f7 (struct U *p)
98 {
99   p->s[2].t.a = 1;
100   p->s[2].t.c = 3;
101   p->s[2].t.d = 4;
102   p->s[2].t.b = 2;
103 }
104 
105 int
main(void)106 main (void)
107 {
108   struct U w __attribute__((aligned));
109   f1 ();
110   c2 (&u);
111   f2 ();
112   c1 (&u.t);
113   f3 ();
114   c2 (&u);
115   f4 ();
116   f5 (&u);
117   c2 (&u);
118   f6 ();
119   f7 (&w);
120   c3 (&w);
121   return 0;
122 }
123