PR c++/67273
[official-gcc.git] / gcc / testsuite / c-c++-common / rotate-4.c
blob44fd1d0bb831718bb6418d8baf40a24073ee207a
1 /* Check rotate pattern detection. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
4 /* Rotates should be recognized only in functions with | instead of + or ^,
5 or in functions that have constant shift counts (unused attribute on y). */
6 /* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 48 "optimized" } } */
8 unsigned int
9 f1 (unsigned int x, int y)
11 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
14 unsigned int
15 f2 (unsigned int x, long int y)
17 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
20 unsigned int
21 f3 (unsigned int x, int y __attribute__((unused)))
23 return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
26 unsigned int
27 f4 (unsigned int x, int y __attribute__((unused)))
29 return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> 1);
32 unsigned short int
33 f5 (unsigned short int x, int y)
35 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
38 unsigned short int
39 f6 (unsigned short int x, long int y)
41 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
44 unsigned char
45 f7 (unsigned char x, int y)
47 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
50 unsigned char
51 f8 (unsigned char x, long int y)
53 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
56 unsigned int
57 f9 (unsigned int x, int y)
59 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
62 unsigned int
63 f10 (unsigned int x, long int y)
65 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
68 unsigned int
69 f11 (unsigned int x, int y __attribute__((unused)))
71 return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
74 unsigned int
75 f12 (unsigned int x, int y __attribute__((unused)))
77 return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x >> 1);
80 unsigned short int
81 f13 (unsigned short int x, int y)
83 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
86 unsigned short int
87 f14 (unsigned short int x, long int y)
89 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
92 unsigned char
93 f15 (unsigned char x, int y)
95 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
98 unsigned char
99 f16 (unsigned char x, long int y)
101 return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
104 unsigned int
105 f17 (unsigned int x, int y)
107 return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
110 unsigned int
111 f18 (unsigned int x, long int y)
113 return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
116 unsigned int
117 f19 (unsigned int x, int y __attribute__((unused)))
119 return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << 1);
122 unsigned int
123 f20 (unsigned int x, int y __attribute__((unused)))
125 return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
128 unsigned short int
129 f21 (unsigned short int x, int y)
131 return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
134 unsigned short int
135 f22 (unsigned short int x, long int y)
137 return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
140 unsigned char
141 f23 (unsigned char x, int y)
143 return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
146 unsigned char
147 f24 (unsigned char x, long int y)
149 return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
152 unsigned int
153 f25 (unsigned int x, int y)
155 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
158 unsigned int
159 f26 (unsigned int x, long int y)
161 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
164 unsigned int
165 f27 (unsigned int x, int y __attribute__((unused)))
167 return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << 1);
170 unsigned int
171 f28 (unsigned int x, int y __attribute__((unused)))
173 return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
176 unsigned short int
177 f29 (unsigned short int x, int y)
179 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
182 unsigned short int
183 f30 (unsigned short int x, long int y)
185 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
188 unsigned char
189 f31 (unsigned char x, int y)
191 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
194 unsigned char
195 f32 (unsigned char x, long int y)
197 return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
200 unsigned int
201 f33 (unsigned int x, int y)
203 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
206 unsigned int
207 f34 (unsigned int x, long int y)
209 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
212 unsigned int
213 f35 (unsigned int x, int y __attribute__((unused)))
215 return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
218 unsigned int
219 f36 (unsigned int x, int y __attribute__((unused)))
221 return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x << 1);
224 unsigned short int
225 f37 (unsigned short int x, int y)
227 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
230 unsigned short int
231 f38 (unsigned short int x, long int y)
233 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
236 unsigned char
237 f39 (unsigned char x, int y)
239 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
242 unsigned char
243 f40 (unsigned char x, long int y)
245 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
248 unsigned int
249 f41 (unsigned int x, int y)
251 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
254 unsigned int
255 f42 (unsigned int x, long int y)
257 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
260 unsigned int
261 f43 (unsigned int x, int y __attribute__((unused)))
263 return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
266 unsigned int
267 f44 (unsigned int x, int y __attribute__((unused)))
269 return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x << 1);
272 unsigned short int
273 f45 (unsigned short int x, int y)
275 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
278 unsigned short int
279 f46 (unsigned short int x, long int y)
281 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
284 unsigned char
285 f47 (unsigned char x, int y)
287 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
290 unsigned char
291 f48 (unsigned char x, long int y)
293 return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
296 unsigned int
297 f49 (unsigned int x, int y)
299 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
302 unsigned int
303 f50 (unsigned int x, long int y)
305 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
308 unsigned int
309 f51 (unsigned int x, int y __attribute__((unused)))
311 return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> 1);
314 unsigned int
315 f52 (unsigned int x, int y __attribute__((unused)))
317 return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
320 unsigned short int
321 f53 (unsigned short int x, int y)
323 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
326 unsigned short int
327 f54 (unsigned short int x, long int y)
329 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
332 unsigned char
333 f55 (unsigned char x, int y)
335 return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
338 unsigned char
339 f56 (unsigned char x, long int y)
341 return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
344 unsigned int
345 f57 (unsigned int x, int y)
347 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
350 unsigned int
351 f58 (unsigned int x, long int y)
353 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
356 unsigned int
357 f59 (unsigned int x, int y __attribute__((unused)))
359 return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> 1);
362 unsigned int
363 f60 (unsigned int x, int y __attribute__((unused)))
365 return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
368 unsigned short int
369 f61 (unsigned short int x, int y)
371 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
374 unsigned short int
375 f62 (unsigned short int x, long int y)
377 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
380 unsigned char
381 f63 (unsigned char x, int y)
383 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
386 unsigned char
387 f64 (unsigned char x, long int y)
389 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
392 unsigned int
393 f65 (unsigned int x, int y)
395 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
398 unsigned int
399 f66 (unsigned int x, long int y)
401 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
404 unsigned int
405 f67 (unsigned int x, int y __attribute__((unused)))
407 return (x << 1) + (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
410 unsigned int
411 f68 (unsigned int x, int y __attribute__((unused)))
413 return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) + (x >> 1);
416 unsigned short int
417 f69 (unsigned short int x, int y)
419 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
422 unsigned short int
423 f70 (unsigned short int x, long int y)
425 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
428 unsigned char
429 f71 (unsigned char x, int y)
431 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ - 1)));
434 unsigned char
435 f72 (unsigned char x, long int y)
437 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ - 1)));
440 unsigned int
441 f73 (unsigned int x, int y)
443 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
446 unsigned int
447 f74 (unsigned int x, long int y)
449 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
452 unsigned int
453 f75 (unsigned int x, int y __attribute__((unused)))
455 return (x << 1) + (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
458 unsigned int
459 f76 (unsigned int x, int y __attribute__((unused)))
461 return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) + (x >> 1);
464 unsigned short int
465 f77 (unsigned short int x, int y)
467 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
470 unsigned short int
471 f78 (unsigned short int x, long int y)
473 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
476 unsigned char
477 f79 (unsigned char x, int y)
479 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
482 unsigned char
483 f80 (unsigned char x, long int y)
485 return (x << y) + (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
488 unsigned int
489 f81 (unsigned int x, int y)
491 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) + (x >> y);
494 unsigned int
495 f82 (unsigned int x, long int y)
497 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) + (x >> y);
500 unsigned int
501 f83 (unsigned int x, int y __attribute__((unused)))
503 return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) + (x >> 1);
506 unsigned int
507 f84 (unsigned int x, int y __attribute__((unused)))
509 return (x << 1) + (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
512 unsigned short int
513 f85 (unsigned short int x, int y)
515 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) + (x >> y);
518 unsigned short int
519 f86 (unsigned short int x, long int y)
521 return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) + (x >> y);
524 unsigned char
525 f87 (unsigned char x, int y)
527 return (x << ((-y) & (__CHAR_BIT__ - 1))) + (x >> y);
530 unsigned char
531 f88 (unsigned char x, long int y)
533 return (x << ((-y) & (__CHAR_BIT__ - 1))) + (x >> y);
536 unsigned int
537 f89 (unsigned int x, int y)
539 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) + (x >> y);
542 unsigned int
543 f90 (unsigned int x, long int y)
545 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) + (x >> y);
548 unsigned int
549 f91 (unsigned int x, int y __attribute__((unused)))
551 return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) + (x >> 1);
554 unsigned int
555 f92 (unsigned int x, int y __attribute__((unused)))
557 return (x << 1) + (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
560 unsigned short int
561 f93 (unsigned short int x, int y)
563 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) + (x >> y);
566 unsigned short int
567 f94 (unsigned short int x, long int y)
569 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) + (x >> y);
572 unsigned char
573 f95 (unsigned char x, int y)
575 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) + (x >> y);
578 unsigned char
579 f96 (unsigned char x, long int y)
581 return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) + (x >> y);