testsuite: Add -Wno-psabi to pr104505.c
[official-gcc.git] / gcc / testsuite / c-c++-common / rotate-8.c
blobf27634af348f0ac906c171a2a7b56f3c971b3081
1 /* PR middle-end/62263 */
2 /* PR middle-end/82498 */
3 /* { dg-do compile } */
4 /* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
5 /* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 23 "optimized" } } */
6 /* { dg-final { scan-tree-dump-not "PHI <" "optimized" } } */
8 #if __SIZEOF_INT__ == 2
9 #define LARGE_UNSIGNED 0x1234U
10 #else
11 #define LARGE_UNSIGNED 0x12345678U
12 #endif
14 unsigned int
15 f1 (unsigned int x, unsigned char y)
17 y %= __CHAR_BIT__ * __SIZEOF_INT__;
18 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
21 unsigned int
22 f2 (unsigned int x, signed char y)
24 y &= __CHAR_BIT__ * __SIZEOF_INT__ - 1;
25 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
28 unsigned int
29 f3 (unsigned int x, unsigned char y)
31 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))));
34 unsigned int
35 f4 (unsigned int x, unsigned char y)
37 y = y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1);
38 return y ? (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) : x;
41 unsigned int
42 f5 (unsigned int x, unsigned char y)
44 y = y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1);
45 return (x << y) | (x >> ((__CHAR_BIT__ * __SIZEOF_INT__ - y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
48 unsigned int
49 f6 (unsigned int x, unsigned char y)
51 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> ((__CHAR_BIT__ * __SIZEOF_INT__ - (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
54 unsigned int
55 f7 (unsigned int x, unsigned char y)
57 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> ((__CHAR_BIT__ * __SIZEOF_INT__ - y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
60 unsigned int
61 f8 (unsigned int x, unsigned char y)
63 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
66 unsigned int
67 f9 (unsigned int x, int y)
69 return (LARGE_UNSIGNED << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (LARGE_UNSIGNED >> (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
72 unsigned int
73 f10 (unsigned int x, int y)
75 return (LARGE_UNSIGNED >> (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (LARGE_UNSIGNED << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
78 unsigned int
79 f11 (unsigned int x, int y)
81 return (LARGE_UNSIGNED >> (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (LARGE_UNSIGNED << (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
84 unsigned int
85 f12 (unsigned int x, int y)
87 return (LARGE_UNSIGNED << (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (LARGE_UNSIGNED >> (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
90 unsigned
91 f13 (unsigned x, unsigned char y)
93 if (y == 0)
94 return x;
95 y %= __CHAR_BIT__ * __SIZEOF_INT__;
96 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
99 unsigned
100 f14 (unsigned x, unsigned y)
102 if (y == 0)
103 return x;
104 y %= __CHAR_BIT__ * __SIZEOF_INT__;
105 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
108 unsigned
109 f15 (unsigned x, unsigned short y)
111 if (y == 0)
112 return x;
113 y %= __CHAR_BIT__ * __SIZEOF_INT__;
114 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
117 unsigned
118 f16 (unsigned x, unsigned char y)
120 y %= __CHAR_BIT__ * __SIZEOF_INT__;
121 if (y == 0)
122 return x;
123 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
126 unsigned
127 f17 (unsigned x, unsigned y)
129 y %= __CHAR_BIT__ * __SIZEOF_INT__;
130 if (y == 0)
131 return x;
132 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
135 unsigned
136 f18 (unsigned x, unsigned short y)
138 y %= __CHAR_BIT__ * __SIZEOF_INT__;
139 if (y == 0)
140 return x;
141 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
144 unsigned
145 f19 (unsigned x, unsigned char y)
147 y %= __CHAR_BIT__ * __SIZEOF_INT__;
148 return (x << y) | (x >> (((unsigned char) -y) % (__CHAR_BIT__ * __SIZEOF_INT__)));
151 unsigned
152 f20 (unsigned x, unsigned int y)
154 y %= __CHAR_BIT__ * __SIZEOF_INT__;
155 return (x << y) | (x >> (-y % (__CHAR_BIT__ * __SIZEOF_INT__)));
158 unsigned
159 f21 (unsigned x, unsigned short y)
161 y %= __CHAR_BIT__ * __SIZEOF_INT__;
162 return (x << y) | (x >> (((unsigned short) -y) % (__CHAR_BIT__ * __SIZEOF_INT__)));
165 unsigned
166 f22 (unsigned x, unsigned char y)
168 y %= __CHAR_BIT__ * __SIZEOF_INT__;
169 return (x << y) | (x >> (-y & ((__CHAR_BIT__ * __SIZEOF_INT__) - 1)));
172 unsigned
173 f23 (unsigned x, unsigned short y)
175 y %= __CHAR_BIT__ * __SIZEOF_INT__;
176 return (x << y) | (x >> (-y & ((__CHAR_BIT__ * __SIZEOF_INT__) - 1)));