Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / sra-13.c
blobd4aa47a05cad20238889f99692224af4a47a0e0a
1 /* Test that SRA replacement can deal with assignments that have
2 sub-replacements on one side and a single scalar replacement on another. */
3 /* { dg-do run } */
4 /* { dg-options "-O1" } */
6 struct A
8 int i1, i2;
9 };
11 struct B
13 long long int l;
16 union U
18 struct A a;
19 struct B b;
22 int b, gi;
23 long gl;
24 union U gu1, gu2;
26 int __attribute__ ((noinline, noclone))
27 foo (void)
29 union U x, y;
30 int r;
32 y = gu1;
33 if (b)
34 y.b.l = gl;
36 x = y;
38 if (!b)
39 r = x.a.i1;
40 else
41 r = 0;
43 gu2 = x;
44 return r;
47 long long int __attribute__ ((noinline, noclone))
48 bar (void)
50 union U x, y;
51 int r;
53 y = gu1;
54 if (b)
55 y.a.i1 = gi;
57 x = y;
59 if (!b)
60 r = x.b.l;
61 else
62 r = 0;
64 gu2 = x;
65 return r;
69 int
70 main (void)
72 int r;
73 long long int s;
75 b = 0;
76 gu1.a.i1 = 123;
77 gu1.a.i2 = 234;
78 r = foo ();
79 if (r != 123)
80 __builtin_abort ();
81 if (gu2.a.i1 != 123)
82 __builtin_abort ();
83 if (gu2.a.i2 != 234)
84 __builtin_abort ();
86 b = 1;
87 gl = 10000001;
88 gu1.b.l = 10000000;
89 r = foo ();
90 if (r != 0)
91 __builtin_abort ();
92 if (gu2.b.l != 10000001)
93 __builtin_abort ();
95 b = 0;
96 gu1.b.l = 20000000;
97 s = bar ();
98 if (s != (int)20000000)
99 __builtin_abort ();
100 if (gu2.b.l != 20000000)
101 __builtin_abort ();
103 b = 1;
104 gi = 456;
105 gu1.a.i1 = 123;
106 gu1.a.i2 = 234;
107 s = bar ();
108 if (s != 0)
109 __builtin_abort ();
110 if (gu2.a.i1 != 456)
111 __builtin_abort ();
113 return 0;