2013-10-21 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / fold-rotate-1.c
blobc04447fb3cf537b764bd01e4dcd49a5645e5b9f6
1 /* PR middle-end/29749 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-original" } */
5 #if __SCHAR_MAX__ == 127
7 unsigned char
8 e1 (unsigned char a)
10 return a >> 5 | a << 3;
13 unsigned char
14 e2 (unsigned char a)
16 return (a & 0xe0) >> 5 | (a & 0x1f) << 3;
19 unsigned char
20 e3 (unsigned char a)
22 return ((a >> 5) & 0x07) | ((a << 3) & 0xf8);
25 #endif
27 #if __SHRT_MAX__ == 32767
29 unsigned short
30 f1 (unsigned short a)
32 return a >> 8 | a << 8;
35 unsigned short
36 f2 (unsigned short a)
38 return (a & 0xff00) >> 8 | (a & 0x00ff) << 8;
41 unsigned short
42 f3 (unsigned short a)
44 return ((a >> 8) & 0x00ff) | ((a << 8) & 0xff00);
47 #endif
49 #if __INT_MAX__ == 2147483647
51 unsigned int
52 g1 (unsigned int a)
54 return a >> 24 | a << 8;
57 unsigned int
58 g2 (unsigned int a)
60 return (a & 0xff000000) >> 24 | (a & 0x00ffffff) << 8;
63 unsigned int
64 g3 (unsigned int a)
66 return ((a >> 24) & 0x000000ff) | ((a << 8) & 0xffffff00U);
69 #endif
71 int i;
73 /* { dg-final { scan-tree-dump-times "&" 0 "original" } } */
74 /* { dg-final { cleanup-tree-dump "original" } } */