libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-bswap-13.c
blob4f5bc9735f907c3a0a964b313fee0c210a5e2a17
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 #if __SIZEOF_INT__ < 4
5 #define int __INT32_TYPE__
6 #endif
8 int test_s32_0_1(int x) { return __builtin_bswap32(x) & 1; }
9 int test_s32_0_2(int x) { return __builtin_bswap32(x) & 2; }
10 int test_s32_0_240(int x) { return __builtin_bswap32(x) & 240; }
11 int test_s32_0_255(int x) { return __builtin_bswap32(x) & 255; }
12 int test_s32_1_1(int x) { return (__builtin_bswap32(x) >> 1) & 1; }
13 int test_s32_7_1(int x) { return (__builtin_bswap32(x) >> 7) & 1; }
14 int test_s32_8_1(int x) { return (__builtin_bswap32(x) >> 8) & 1; }
15 int test_s32_8_240(int x) { return (__builtin_bswap32(x) >> 8) & 240; }
16 int test_s32_8_255(int x) { return (__builtin_bswap32(x) >> 8) & 255; }
17 int test_s32_15_1(int x) { return (__builtin_bswap32(x) >> 15) & 1; }
18 int test_s32_16_1(int x) { return (__builtin_bswap32(x) >> 16) & 1; }
19 int test_s32_16_240(int x) { return (__builtin_bswap32(x) >> 16) & 240; }
20 int test_s32_16_255(int x) { return (__builtin_bswap32(x) >> 16) & 255; }
21 int test_s32_24_1(int x) { return (__builtin_bswap32(x) >> 24) & 1; }
22 int test_s32_24_240(int x) { return (__builtin_bswap32(x) >> 24) & 240; }
23 int test_s32_24_255(int x) { return (__builtin_bswap32(x) >> 24) & 255; }
24 int test_s32_31_1(int x) { return (__builtin_bswap32(x) >> 31) & 1; }
26 int test_S32_0_1(int x) { return (int)__builtin_bswap32(x) & 1; }
27 int test_S32_0_2(int x) { return (int)__builtin_bswap32(x) & 2; }
28 int test_S32_0_240(int x) { return (int)__builtin_bswap32(x) & 240; }
29 int test_S32_0_255(int x) { return (int)__builtin_bswap32(x) & 255; }
30 int test_S32_1_1(int x) { return ((int)__builtin_bswap32(x) >> 1) & 1; }
31 int test_S32_7_1(int x) { return ((int)__builtin_bswap32(x) >> 7) & 1; }
32 int test_S32_8_1(int x) { return ((int)__builtin_bswap32(x) >> 8) & 1; }
33 int test_S32_8_240(int x) { return ((int)__builtin_bswap32(x) >> 8) & 240; }
34 int test_S32_8_255(int x) { return ((int)__builtin_bswap32(x) >> 8) & 255; }
35 int test_S32_15_1(int x) { return ((int)__builtin_bswap32(x) >> 15) & 1; }
36 int test_S32_16_1(int x) { return ((int)__builtin_bswap32(x) >> 16) & 1; }
37 int test_S32_16_240(int x) { return ((int)__builtin_bswap32(x) >> 16) & 240; }
38 int test_S32_16_255(int x) { return ((int)__builtin_bswap32(x) >> 16) & 255; }
39 int test_S32_24_1(int x) { return ((int)__builtin_bswap32(x) >> 24) & 1; }
40 int test_S32_24_240(int x) { return ((int)__builtin_bswap32(x) >> 24) & 240; }
41 int test_S32_24_255(int x) { return ((int)__builtin_bswap32(x) >> 24) & 255; }
42 int test_S32_31_1(int x) { return ((int)__builtin_bswap32(x) >> 31) & 1; }
44 unsigned int test_u32_24_255(unsigned int x) {
45 return (__builtin_bswap32(x) >> 24) & 255;
48 long long test_s64_0_1(long long x) {
49 return __builtin_bswap64(x) & 1;
51 long long test_s64_0_2(long long x) {
52 return __builtin_bswap64(x) & 2;
54 long long test_s64_0_240(long long x) {
55 return __builtin_bswap64(x) & 240;
57 long long test_s64_0_255(long long x) {
58 return __builtin_bswap64(x) & 255;
60 long long test_s64_7_1(long long x) {
61 return (__builtin_bswap64(x) >> 7) & 1;
63 long long test_s64_8_1(long long x) {
64 return (__builtin_bswap64(x) >> 8) & 1;
66 long long test_s64_8_240(long long x) {
67 return (__builtin_bswap64(x) >> 56) & 240;
69 long long test_s64_8_255(long long x) {
70 return (__builtin_bswap64(x) >> 8) & 255;
72 long long test_s64_9_1(long long x) {
73 return (__builtin_bswap64(x) >> 9) & 1;
75 long long test_s64_31_1(long long x) {
76 return (__builtin_bswap64(x) >> 31) & 1;
78 long long test_s64_32_1(long long x) {
79 return (__builtin_bswap64(x) >> 32) & 1;
81 long long test_s64_32_240(long long x) {
82 return (__builtin_bswap64(x) >> 32) & 240;
84 long long test_s64_32_255(long long x) {
85 return (__builtin_bswap64(x) >> 32) & 255;
87 long long test_s64_33_1(long long x) {
88 return (__builtin_bswap64(x) >> 33) & 1;
90 long long test_s64_48_1(long long x) {
91 return (__builtin_bswap64(x) >> 48) & 1;
93 long long test_s64_48_240(long long x) {
94 return (__builtin_bswap64(x) >> 48) & 240;
96 long long test_s64_48_255(long long x) {
97 return (__builtin_bswap64(x) >> 48) & 255;
99 long long test_s64_56_1(long long x) {
100 return (__builtin_bswap64(x) >> 56) & 1;
102 long long test_s64_56_240(long long x) {
103 return (__builtin_bswap64(x) >> 56) & 240;
105 long long test_s64_56_255(long long x) {
106 return (__builtin_bswap64(x) >> 56) & 255;
108 long long test_s64_57_1(long long x) {
109 return (__builtin_bswap64(x) >> 57) & 1;
111 long long test_s64_63_1(long long x) {
112 return (__builtin_bswap64(x) >> 63) & 1;
115 long long test_S64_0_1(long long x) {
116 return (long long)__builtin_bswap64(x) & 1;
118 long long test_S64_0_2(long long x) {
119 return (long long)__builtin_bswap64(x) & 2;
121 long long test_S64_0_240(long long x) {
122 return (long long)__builtin_bswap64(x) & 240;
124 long long test_S64_0_255(long long x) {
125 return (long long)__builtin_bswap64(x) & 255;
127 long long test_S64_7_1(long long x) {
128 return ((long long)__builtin_bswap64(x) >> 7) & 1;
130 long long test_S64_8_1(long long x) {
131 return ((long long)__builtin_bswap64(x) >> 8) & 1;
133 long long test_S64_8_240(long long x) {
134 return ((long long)__builtin_bswap64(x) >> 56) & 240;
136 long long test_S64_8_255(long long x) {
137 return ((long long)__builtin_bswap64(x) >> 8) & 255;
139 long long test_S64_9_1(long long x) {
140 return ((long long)__builtin_bswap64(x) >> 9) & 1;
142 long long test_S64_31_1(long long x) {
143 return ((long long)__builtin_bswap64(x) >> 31) & 1;
145 long long test_S64_32_1(long long x) {
146 return ((long long)__builtin_bswap64(x) >> 32) & 1;
148 long long test_S64_32_240(long long x) {
149 return ((long long)__builtin_bswap64(x) >> 32) & 240;
151 long long test_S64_32_255(long long x) {
152 return ((long long)__builtin_bswap64(x) >> 32) & 255;
154 long long test_S64_33_1(long long x) {
155 return ((long long)__builtin_bswap64(x) >> 33) & 1;
157 long long test_S64_48_1(long long x) {
158 return ((long long)__builtin_bswap64(x) >> 48) & 1;
160 long long test_S64_48_240(long long x) {
161 return ((long long)__builtin_bswap64(x) >> 48) & 240;
163 long long test_S64_48_255(long long x) {
164 return ((long long)__builtin_bswap64(x) >> 48) & 255;
166 long long test_S64_56_1(long long x) {
167 return ((long long)__builtin_bswap64(x) >> 56) & 1;
169 long long test_S64_56_240(long long x) {
170 return ((long long)__builtin_bswap64(x) >> 56) & 240;
172 long long test_S64_56_255(long long x) {
173 return ((long long)__builtin_bswap64(x) >> 56) & 255;
175 long long test_S64_57_1(long long x) {
176 return ((long long)__builtin_bswap64(x) >> 57) & 1;
178 long long test_S64_63_1(long long x) {
179 return ((long long)__builtin_bswap64(x) >> 63) & 1;
182 unsigned long long test_u64_56_255(unsigned long long x) {
183 return (__builtin_bswap64(x) >> 56) & 255;
186 short test_s16_0_1(short x) {
187 return __builtin_bswap16(x) & 1;
189 short test_s16_0_240(short x) {
190 return __builtin_bswap16(x) & 240;
192 short test_s16_0_255(short x) {
193 return __builtin_bswap16(x) & 255;
195 short test_s16_1_1(short x) {
196 return (__builtin_bswap16(x) >> 1) & 1;
198 short test_s16_7_1(short x) {
199 return (__builtin_bswap16(x) >> 7) & 1;
201 short test_s16_8_1(short x) {
202 return (__builtin_bswap16(x) >> 8) & 1;
204 short test_s16_8_240(short x) {
205 return (__builtin_bswap16(x) >> 8) & 240;
207 short test_s16_8_255(short x) {
208 return (__builtin_bswap16(x) >> 8) & 255;
210 short test_s16_9_1(short x) {
211 return (__builtin_bswap16(x) >> 9) & 1;
213 short test_s16_15_1(short x) {
214 return (__builtin_bswap16(x) >> 15) & 1;
217 short test_S16_0_1(short x) {
218 return (short)__builtin_bswap16(x) & 1;
220 short test_S16_0_240(short x) {
221 return (short)__builtin_bswap16(x) & 240;
223 short test_S16_0_255(short x) {
224 return (short)__builtin_bswap16(x) & 255;
226 short test_S16_1_1(short x) {
227 return ((short)__builtin_bswap16(x) >> 1) & 1;
229 short test_S16_7_1(short x) {
230 return ((short)__builtin_bswap16(x) >> 7) & 1;
232 short test_S16_8_1(short x) {
233 return ((short)__builtin_bswap16(x) >> 8) & 1;
235 short test_S16_8_240(short x) {
236 return ((short)__builtin_bswap16(x) >> 8) & 240;
238 short test_S16_8_255(short x) {
239 return ((short)__builtin_bswap16(x) >> 8) & 255;
241 short test_S16_9_1(short x) {
242 return ((short)__builtin_bswap16(x) >> 9) & 1;
244 short test_S16_15_1(short x) {
245 return ((short)__builtin_bswap16(x) >> 15) & 1;
248 unsigned short test_u16_8_255(unsigned short x) {
249 return (__builtin_bswap16(x) >> 8) & 255;
253 /* Shifts only */
254 int test_s32_24(int x) {
255 return __builtin_bswap32(x) >> 24;
257 int test_s32_25(int x) {
258 return __builtin_bswap32(x) >> 25;
260 int test_s32_30(int x) {
261 return __builtin_bswap32(x) >> 30;
263 int test_s32_31(int x) {
264 return __builtin_bswap32(x) >> 31;
267 unsigned int test_u32_24(unsigned int x) {
268 return __builtin_bswap32(x) >> 24;
270 unsigned int test_u32_25(unsigned int x) {
271 return __builtin_bswap32(x) >> 25;
273 unsigned int test_u32_30(unsigned int x) {
274 return __builtin_bswap32(x) >> 30;
276 unsigned int test_u32_31(unsigned int x) {
277 return __builtin_bswap32(x) >> 31;
280 long long test_s64_56(long long x) {
281 return __builtin_bswap64(x) >> 56;
283 long long test_s64_57(long long x) {
284 return __builtin_bswap64(x) >> 57;
286 long long test_s64_62(long long x) {
287 return __builtin_bswap64(x) >> 62;
289 long long test_s64_63(long long x) {
290 return __builtin_bswap64(x) >> 63;
293 unsigned long long test_u64_56(unsigned long long x) {
294 return __builtin_bswap64(x) >> 56;
296 unsigned long long test_u64_57(unsigned long long x) {
297 return __builtin_bswap64(x) >> 57;
299 unsigned long long test_u64_62(unsigned long long x) {
300 return __builtin_bswap64(x) >> 62;
302 unsigned long long test_u64_63(unsigned long long x) {
303 return __builtin_bswap64(x) >> 63;
306 short test_s16_8(short x) {
307 return __builtin_bswap16(x) >> 8;
309 short test_s16_9(short x) {
310 return __builtin_bswap16(x) >> 9;
312 short test_s16_14(short x) {
313 return __builtin_bswap16(x) >> 14;
315 short test_s16_15(short x) {
316 return __builtin_bswap16(x) >> 15;
319 unsigned short test_u16_8(unsigned short x) {
320 return __builtin_bswap16(x) >> 8;
322 unsigned short test_u16_9(unsigned short x) {
323 return __builtin_bswap16(x) >> 9;
325 unsigned short test_u16_14(unsigned short x) {
326 return __builtin_bswap16(x) >> 14;
328 unsigned short test_u16_15(unsigned short x) {
329 return __builtin_bswap16(x) >> 15;
332 /* { dg-final { scan-tree-dump-not "__builtin_bswap" "optimized" } } */