* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / c-c++-common / rotate-8.c
blob9ba3e940930215e92303aa31b9fddd30fa8fd278
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 unsigned int
9 f1 (unsigned int x, unsigned char y)
11 y %= __CHAR_BIT__ * __SIZEOF_INT__;
12 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
15 unsigned int
16 f2 (unsigned int x, signed char y)
18 y &= __CHAR_BIT__ * __SIZEOF_INT__ - 1;
19 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
22 unsigned int
23 f3 (unsigned int x, unsigned char y)
25 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))));
28 unsigned int
29 f4 (unsigned int x, unsigned char y)
31 y = y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1);
32 return y ? (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) : x;
35 unsigned int
36 f5 (unsigned int x, unsigned char y)
38 y = y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1);
39 return (x << y) | (x >> ((__CHAR_BIT__ * __SIZEOF_INT__ - y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
42 unsigned int
43 f6 (unsigned int x, unsigned char y)
45 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> ((__CHAR_BIT__ * __SIZEOF_INT__ - (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
48 unsigned int
49 f7 (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)));
54 unsigned int
55 f8 (unsigned int x, unsigned char y)
57 return (x << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
60 unsigned int
61 f9 (unsigned int x, int y)
63 return (0x12345678U << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (0x12345678U >> (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
66 unsigned int
67 f10 (unsigned int x, int y)
69 return (0x12345678U >> (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (0x12345678U << (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
72 unsigned int
73 f11 (unsigned int x, int y)
75 return (0x12345678U >> (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (0x12345678U << (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
78 unsigned int
79 f12 (unsigned int x, int y)
81 return (0x12345678U << (-y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (0x12345678U >> (y & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
84 unsigned
85 f13 (unsigned x, unsigned char y)
87 if (y == 0)
88 return x;
89 y %= __CHAR_BIT__ * __SIZEOF_INT__;
90 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
93 unsigned
94 f14 (unsigned x, unsigned y)
96 if (y == 0)
97 return x;
98 y %= __CHAR_BIT__ * __SIZEOF_INT__;
99 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
102 unsigned
103 f15 (unsigned x, unsigned short y)
105 if (y == 0)
106 return x;
107 y %= __CHAR_BIT__ * __SIZEOF_INT__;
108 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
111 unsigned
112 f16 (unsigned x, unsigned char y)
114 y %= __CHAR_BIT__ * __SIZEOF_INT__;
115 if (y == 0)
116 return x;
117 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
120 unsigned
121 f17 (unsigned x, unsigned y)
123 y %= __CHAR_BIT__ * __SIZEOF_INT__;
124 if (y == 0)
125 return x;
126 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
129 unsigned
130 f18 (unsigned x, unsigned short y)
132 y %= __CHAR_BIT__ * __SIZEOF_INT__;
133 if (y == 0)
134 return x;
135 return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
138 unsigned
139 f19 (unsigned x, unsigned char y)
141 y %= __CHAR_BIT__ * __SIZEOF_INT__;
142 return (x << y) | (x >> (((unsigned char) -y) % (__CHAR_BIT__ * __SIZEOF_INT__)));
145 unsigned
146 f20 (unsigned x, unsigned int y)
148 y %= __CHAR_BIT__ * __SIZEOF_INT__;
149 return (x << y) | (x >> (-y % (__CHAR_BIT__ * __SIZEOF_INT__)));
152 unsigned
153 f21 (unsigned x, unsigned short y)
155 y %= __CHAR_BIT__ * __SIZEOF_INT__;
156 return (x << y) | (x >> (((unsigned short) -y) % (__CHAR_BIT__ * __SIZEOF_INT__)));
159 unsigned
160 f22 (unsigned x, unsigned char y)
162 y %= __CHAR_BIT__ * __SIZEOF_INT__;
163 return (x << y) | (x >> (-y & ((__CHAR_BIT__ * __SIZEOF_INT__) - 1)));
166 unsigned
167 f23 (unsigned x, unsigned short y)
169 y %= __CHAR_BIT__ * __SIZEOF_INT__;
170 return (x << y) | (x >> (-y & ((__CHAR_BIT__ * __SIZEOF_INT__) - 1)));