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" } } */
9 f1 (unsigned int x
, unsigned int y
)
11 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
15 f2 (unsigned int x
, unsigned long int y
)
17 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
21 f3 (unsigned int x
, int y
__attribute__((unused
)))
23 return (x
<< 1) | (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
27 f4 (unsigned int x
, int y
__attribute__((unused
)))
29 return (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
>> 1);
33 f5 (unsigned short int x
, unsigned int y
)
35 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
39 f6 (unsigned short int x
, unsigned long int y
)
41 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
45 f7 (unsigned char x
, unsigned int y
)
47 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
- 1)));
51 f8 (unsigned char x
, unsigned long int y
)
53 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
- 1)));
57 f9 (unsigned int x
, unsigned int y
)
59 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
63 f10 (unsigned int x
, unsigned long int y
)
65 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
69 f11 (unsigned int x
, int y
__attribute__((unused
)))
71 return (x
<< 1) | (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
75 f12 (unsigned int x
, int y
__attribute__((unused
)))
77 return (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) | (x
>> 1);
81 f13 (unsigned short int x
, unsigned int y
)
83 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
87 f14 (unsigned short int x
, unsigned long int y
)
89 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
93 f15 (unsigned char x
, unsigned int y
)
95 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
99 f16 (unsigned char x
, unsigned long int y
)
101 return (x
<< y
) | (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
105 f17 (unsigned int x
, unsigned int y
)
107 return (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
<< y
);
111 f18 (unsigned int x
, unsigned long int y
)
113 return (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
<< y
);
117 f19 (unsigned int x
, int y
__attribute__((unused
)))
119 return (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
<< 1);
123 f20 (unsigned int x
, int y
__attribute__((unused
)))
125 return (x
>> 1) ^ (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
129 f21 (unsigned short int x
, unsigned int y
)
131 return (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) ^ (x
<< y
);
135 f22 (unsigned short int x
, unsigned long int y
)
137 return (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) ^ (x
<< y
);
141 f23 (unsigned char x
, unsigned int y
)
143 return (x
>> ((-y
) & (__CHAR_BIT__
- 1))) ^ (x
<< y
);
147 f24 (unsigned char x
, unsigned long int y
)
149 return (x
>> ((-y
) & (__CHAR_BIT__
- 1))) ^ (x
<< y
);
153 f25 (unsigned int x
, unsigned int y
)
155 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
<< y
);
159 f26 (unsigned int x
, unsigned long int y
)
161 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
<< y
);
165 f27 (unsigned int x
, int y
__attribute__((unused
)))
167 return (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
<< 1);
171 f28 (unsigned int x
, int y
__attribute__((unused
)))
173 return (x
>> 1) ^ (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
177 f29 (unsigned short int x
, unsigned int y
)
179 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) ^ (x
<< y
);
183 f30 (unsigned short int x
, unsigned long int y
)
185 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) ^ (x
<< y
);
189 f31 (unsigned char x
, unsigned int y
)
191 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) ^ (x
<< y
);
195 f32 (unsigned char x
, unsigned long int y
)
197 return (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) ^ (x
<< y
);
201 f33 (unsigned int x
, unsigned int y
)
203 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
207 f34 (unsigned int x
, unsigned long int y
)
209 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
213 f35 (unsigned int x
, int y
__attribute__((unused
)))
215 return (x
>> 1) | (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
219 f36 (unsigned int x
, int y
__attribute__((unused
)))
221 return (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
<< 1);
225 f37 (unsigned short int x
, unsigned int y
)
227 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
231 f38 (unsigned short int x
, unsigned long int y
)
233 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
237 f39 (unsigned char x
, unsigned int y
)
239 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
- 1)));
243 f40 (unsigned char x
, unsigned long int y
)
245 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
- 1)));
249 f41 (unsigned int x
, unsigned int y
)
251 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
255 f42 (unsigned int x
, unsigned long int y
)
257 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
261 f43 (unsigned int x
, int y
__attribute__((unused
)))
263 return (x
>> 1) | (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
267 f44 (unsigned int x
, int y
__attribute__((unused
)))
269 return (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) | (x
<< 1);
273 f45 (unsigned short int x
, unsigned int y
)
275 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
279 f46 (unsigned short int x
, unsigned long int y
)
281 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
285 f47 (unsigned char x
, unsigned int y
)
287 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
291 f48 (unsigned char x
, unsigned long int y
)
293 return (x
>> y
) | (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
297 f49 (unsigned int x
, unsigned int y
)
299 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
>> y
);
303 f50 (unsigned int x
, unsigned long int y
)
305 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
>> y
);
309 f51 (unsigned int x
, int y
__attribute__((unused
)))
311 return (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) ^ (x
>> 1);
315 f52 (unsigned int x
, int y
__attribute__((unused
)))
317 return (x
<< 1) ^ (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
321 f53 (unsigned short int x
, unsigned int y
)
323 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) ^ (x
>> y
);
327 f54 (unsigned short int x
, unsigned long int y
)
329 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) ^ (x
>> y
);
333 f55 (unsigned char x
, unsigned int y
)
335 return (x
<< ((-y
) & (__CHAR_BIT__
- 1))) ^ (x
>> y
);
339 f56 (unsigned char x
, unsigned long int y
)
341 return (x
<< ((-y
) & (__CHAR_BIT__
- 1))) ^ (x
>> y
);
345 f57 (unsigned int x
, unsigned int y
)
347 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
>> y
);
351 f58 (unsigned int x
, unsigned long int y
)
353 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
>> y
);
357 f59 (unsigned int x
, int y
__attribute__((unused
)))
359 return (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) ^ (x
>> 1);
363 f60 (unsigned int x
, int y
__attribute__((unused
)))
365 return (x
<< 1) ^ (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
369 f61 (unsigned short int x
, unsigned int y
)
371 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) ^ (x
>> y
);
375 f62 (unsigned short int x
, unsigned long int y
)
377 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) ^ (x
>> y
);
381 f63 (unsigned char x
, unsigned int y
)
383 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) ^ (x
>> y
);
387 f64 (unsigned char x
, unsigned long int y
)
389 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) ^ (x
>> y
);
393 f65 (unsigned int x
, unsigned int y
)
395 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
399 f66 (unsigned int x
, unsigned long int y
)
401 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
405 f67 (unsigned int x
, int y
__attribute__((unused
)))
407 return (x
<< 1) + (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
411 f68 (unsigned int x
, int y
__attribute__((unused
)))
413 return (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) + (x
>> 1);
417 f69 (unsigned short int x
, unsigned int y
)
419 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
423 f70 (unsigned short int x
, unsigned long int y
)
425 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1)));
429 f71 (unsigned char x
, unsigned int y
)
431 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
- 1)));
435 f72 (unsigned char x
, unsigned long int y
)
437 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
- 1)));
441 f73 (unsigned int x
, unsigned int y
)
443 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
447 f74 (unsigned int x
, unsigned long int y
)
449 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
453 f75 (unsigned int x
, int y
__attribute__((unused
)))
455 return (x
<< 1) + (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
459 f76 (unsigned int x
, int y
__attribute__((unused
)))
461 return (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) + (x
>> 1);
465 f77 (unsigned short int x
, unsigned int y
)
467 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
471 f78 (unsigned short int x
, unsigned long int y
)
473 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1)));
477 f79 (unsigned char x
, unsigned int y
)
479 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
483 f80 (unsigned char x
, unsigned long int y
)
485 return (x
<< y
) + (x
>> ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1)));
489 f81 (unsigned int x
, unsigned int y
)
491 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) + (x
>> y
);
495 f82 (unsigned int x
, unsigned long int y
)
497 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) + (x
>> y
);
501 f83 (unsigned int x
, int y
__attribute__((unused
)))
503 return (x
<< ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) + (x
>> 1);
507 f84 (unsigned int x
, int y
__attribute__((unused
)))
509 return (x
<< 1) + (x
>> ((-1) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
513 f85 (unsigned short int x
, unsigned int y
)
515 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) + (x
>> y
);
519 f86 (unsigned short int x
, unsigned long int y
)
521 return (x
<< ((-y
) & (__CHAR_BIT__
* __SIZEOF_SHORT__
- 1))) + (x
>> y
);
525 f87 (unsigned char x
, unsigned int y
)
527 return (x
<< ((-y
) & (__CHAR_BIT__
- 1))) + (x
>> y
);
531 f88 (unsigned char x
, unsigned long int y
)
533 return (x
<< ((-y
) & (__CHAR_BIT__
- 1))) + (x
>> y
);
537 f89 (unsigned int x
, unsigned int y
)
539 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) + (x
>> y
);
543 f90 (unsigned int x
, unsigned long int y
)
545 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) + (x
>> y
);
549 f91 (unsigned int x
, int y
__attribute__((unused
)))
551 return (x
<< ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1))) + (x
>> 1);
555 f92 (unsigned int x
, int y
__attribute__((unused
)))
557 return (x
<< 1) + (x
>> ((-1) & (__CHAR_BIT__
* sizeof (unsigned int) - 1)));
561 f93 (unsigned short int x
, unsigned int y
)
563 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) + (x
>> y
);
567 f94 (unsigned short int x
, unsigned long int y
)
569 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned short) - 1))) + (x
>> y
);
573 f95 (unsigned char x
, unsigned int y
)
575 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) + (x
>> y
);
579 f96 (unsigned char x
, unsigned long int y
)
581 return (x
<< ((-y
) & (__CHAR_BIT__
* sizeof (unsigned char) - 1))) + (x
>> y
);