2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr57233.c
blob58c05348b85df88b879b56726af36ae8538fc3a7
1 /* PR tree-optimization/57233 */
2 /* { dg-do run { target { ilp32 || lp64 } } } */
3 /* { dg-options "-O2" } */
5 typedef unsigned V4 __attribute__((vector_size(4 * sizeof (int))));
6 typedef unsigned V8 __attribute__((vector_size(8 * sizeof (int))));
7 typedef unsigned V16 __attribute__((vector_size(16 * sizeof (int))));
8 V4 a, b, g;
9 V8 c, d, h;
10 V16 e, f, j;
12 __attribute__((noinline)) void
13 f1 (void)
15 a = (a << 2) | (a >> 30);
18 __attribute__((noinline)) void
19 f2 (void)
21 a = (a << 30) | (a >> 2);
24 __attribute__((noinline)) void
25 f3 (void)
27 a = (a << b) | (a >> (32 - b));
30 __attribute__((noinline, noclone)) void
31 f4 (int x)
33 a = (a << x) | (a >> (32 - x));
36 __attribute__((noinline)) void
37 f5 (void)
39 c = (c << 2) | (c >> 30);
42 __attribute__((noinline)) void
43 f6 (void)
45 c = (c << 30) | (c >> 2);
48 __attribute__((noinline)) void
49 f7 (void)
51 c = (c << d) | (c >> (32 - d));
54 __attribute__((noinline, noclone)) void
55 f8 (int x)
57 c = (c << x) | (c >> (32 - x));
60 __attribute__((noinline)) void
61 f9 (void)
63 e = (e << 2) | (e >> 30);
66 __attribute__((noinline)) void
67 f10 (void)
69 e = (e << 30) | (e >> 2);
72 __attribute__((noinline)) void
73 f11 (void)
75 e = (e << f) | (e >> (32 - f));
78 __attribute__((noinline, noclone)) void
79 f12 (int x)
81 e = (e << x) | (e >> (32 - x));
84 unsigned
85 r (void)
87 static unsigned x = 0xdeadbeefU;
88 static unsigned y = 0x12347654U;
89 static unsigned z = 0x1a2b3c4dU;
90 static unsigned w = 0x87654321U;
91 unsigned t = x ^ (x << 11);
92 x = y;
93 y = z;
94 z = w;
95 w = w ^ (w >> 19) ^ t ^ (t >> 8);
96 return w;
99 void
100 init (unsigned int *p, int count, int mod)
102 int i;
103 for (i = 0; i < count; i++)
105 unsigned int v = r ();
106 if (mod)
107 v = (v % 31) + 1;
108 p[i] = v;
112 void
113 check (unsigned int *p, unsigned int *q, int count, unsigned int *s, int ss)
115 int i;
116 for (i = 0; i < count; i++)
118 if (s)
119 ss = s[i];
120 if (p[i] != ((q[i] << ss) | (q[i] >> (32 - ss))))
121 __builtin_abort ();
126 main ()
128 init ((unsigned int *) &a, 4, 0);
129 init ((unsigned int *) &b, 4, 1);
130 init ((unsigned int *) &c, 8, 0);
131 init ((unsigned int *) &d, 8, 1);
132 init ((unsigned int *) &e, 16, 0);
133 init ((unsigned int *) &f, 16, 1);
134 g = a;
135 h = c;
136 j = e;
137 f1 ();
138 f5 ();
139 f9 ();
140 check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 2);
141 check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 2);
142 check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 2);
143 g = a;
144 h = c;
145 j = e;
146 f2 ();
147 f6 ();
148 f10 ();
149 check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 30);
150 check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 30);
151 check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 30);
152 g = a;
153 h = c;
154 j = e;
155 f3 ();
156 f7 ();
157 f11 ();
158 check ((unsigned int *) &a, (unsigned int *) &g, 4, (unsigned int *) &b, 0);
159 check ((unsigned int *) &c, (unsigned int *) &h, 8, (unsigned int *) &d, 0);
160 check ((unsigned int *) &e, (unsigned int *) &j, 16, (unsigned int *) &f, 0);
161 g = a;
162 h = c;
163 j = e;
164 f4 (5);
165 f8 (5);
166 f12 (5);
167 check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 5);
168 check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 5);
169 check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 5);
170 return 0;