1 /* PR rtl-optimization/38245 */
2 /* { dg-do run } */
3 /* { dg-additional-sources "pr38245-4.c" } */
4 /* { dg-options "-O2" } */
5 
6 #include "pr38245-3.h"
7 
8 extern void abort (void);
9 
10 struct A { int i, j; union { short s[4]; long long l; }; char pad[512]; } a;
11 int globv = 6;
12 
13 void __attribute__((noinline))
f1(void)14 f1 (void)
15 {
16   a.s[2] = b1 (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
17 	       6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21);
18   a.l = 6;
19 }
20 
21 void __attribute__((noinline))
f2(void)22 f2 (void)
23 {
24   a.s[2] = b2 (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
25 	       6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21);
26   a.l = 6;
27 }
28 
29 void __attribute__((noinline))
f3(void)30 f3 (void)
31 {
32   struct B b = { 30, 31, { 32, 33 } };
33   a.s[2] = b3 (6, 7, 8, 9, 10, 11, 12, b, 14, b, 16, b, 18, 19, 20, 21,
34 	       6, b, 8, b, 10, 11, 12, 13, 14, b, 16, b, 18, 19, 20, 21);
35   a.l = 6;
36 }
37 
38 void __attribute__((noinline))
f4(void)39 f4 (void)
40 {
41   struct B b = { 30, 31, { 32, 33 } };
42   a.s[2] = b4 (6, 7, 8, 9, 10, 11, 12, b, 14, b, 16, b, 18, 19, 20, 21,
43 	       6, b, 8, b, 10, 11, 12, 13, 14, b, 16, b, 18, 19, 20, 21);
44   a.l = 6;
45 }
46 
47 void __attribute__((noinline))
f5(void)48 f5 (void)
49 {
50   a.s[2] = b5 (6.0, 7, 8, 9, 10, 11, 21.0, 22.0, 23.0);
51   a.l = 6;
52 }
53 
54 void __attribute__((noinline))
f6(void)55 f6 (void)
56 {
57   a.s[2] = b6 (6.0, 7, 8, 9, 10, 11, 21.0, 22.0, 23.0);
58   a.l = 6;
59 }
60 
61 void __attribute__((noinline))
f7(void)62 f7 (void)
63 {
64   a.s[2] = b7 (6, 7);
65   a.l = 6;
66 }
67 
68 void __attribute__((noinline))
f8(void)69 f8 (void)
70 {
71   a.s[2] = b8 (6, 7);
72   a.l = 6;
73 }
74 
75 void __attribute__((noinline))
f9(void)76 f9 (void)
77 {
78   a.s[2] = b9 (6, 7, 8, 9, 10, 11, 12);
79   a.l = 6;
80 }
81 
82 void __attribute__((noinline))
f10(void)83 f10 (void)
84 {
85   a.s[2] = b10 (6, 7, 8, 9, 10, 11, 12);
86   a.l = 6;
87 }
88 
89 int
main(void)90 main (void)
91 {
92   char buf[256];
93   int i;
94   for (i = 0; i < (int) sizeof buf; i++)
95     buf[i] = i;
96   asm volatile ("" : : "r" (buf) : "memory");
97   f1 ();
98   f2 ();
99   f3 ();
100   f4 ();
101   f5 ();
102   f6 ();
103   f7 ();
104   f8 ();
105   f9 ();
106   f10 ();
107   asm volatile ("" : : "r" (buf) : "memory");
108   for (i = 0; i < (int) sizeof buf; i++)
109     if (buf[i] != (char) i)
110       abort ();
111   return 0;
112 }
113