Debian Codegraph @

gcc/testsuite/gcc.dg/builtin-bswap-13.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
4 #if __SIZEOF_INT__ < 4
5 #define int __INT32_TYPE__
6 #endif
7
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; }
25
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; }
43
44 unsigned int test_u32_24_255(unsigned int x) {
45 return (__builtin_bswap32(x) >> 24) & 255;
46 }
47
48 long long test_s64_0_1(long long x) {
49 return __builtin_bswap64(x) & 1;
50 }
51 long long test_s64_0_2(long long x) {
52 return __builtin_bswap64(x) & 2;
53 }
54 long long test_s64_0_240(long long x) {
55 return __builtin_bswap64(x) & 240;
56 }
57 long long test_s64_0_255(long long x) {
58 return __builtin_bswap64(x) & 255;
59 }
60 long long test_s64_7_1(long long x) {
61 return (__builtin_bswap64(x) >> 7) & 1;
62 }
63 long long test_s64_8_1(long long x) {
64 return (__builtin_bswap64(x) >> 8) & 1;
65 }
66 long long test_s64_8_240(long long x) {
67 return (__builtin_bswap64(x) >> 56) & 240;
68 }
69 long long test_s64_8_255(long long x) {
70 return (__builtin_bswap64(x) >> 8) & 255;
71 }
72 long long test_s64_9_1(long long x) {
73 return (__builtin_bswap64(x) >> 9) & 1;
74 }
75 long long test_s64_31_1(long long x) {
76 return (__builtin_bswap64(x) >> 31) & 1;
77 }
78 long long test_s64_32_1(long long x) {
79 return (__builtin_bswap64(x) >> 32) & 1;
80 }
81 long long test_s64_32_240(long long x) {
82 return (__builtin_bswap64(x) >> 32) & 240;
83 }
84 long long test_s64_32_255(long long x) {
85 return (__builtin_bswap64(x) >> 32) & 255;
86 }
87 long long test_s64_33_1(long long x) {
88 return (__builtin_bswap64(x) >> 33) & 1;
89 }
90 long long test_s64_48_1(long long x) {
91 return (__builtin_bswap64(x) >> 48) & 1;
92 }
93 long long test_s64_48_240(long long x) {
94 return (__builtin_bswap64(x) >> 48) & 240;
95 }
96 long long test_s64_48_255(long long x) {
97 return (__builtin_bswap64(x) >> 48) & 255;
98 }
99 long long test_s64_56_1(long long x) {
100 return (__builtin_bswap64(x) >> 56) & 1;
101 }
102 long long test_s64_56_240(long long x) {
103 return (__builtin_bswap64(x) >> 56) & 240;
104 }
105 long long test_s64_56_255(long long x) {
106 return (__builtin_bswap64(x) >> 56) & 255;
107 }
108 long long test_s64_57_1(long long x) {
109 return (__builtin_bswap64(x) >> 57) & 1;
110 }
111 long long test_s64_63_1(long long x) {
112 return (__builtin_bswap64(x) >> 63) & 1;
113 }
114
115 long long test_S64_0_1(long long x) {
116 return (long long)__builtin_bswap64(x) & 1;
117 }
118 long long test_S64_0_2(long long x) {
119 return (long long)__builtin_bswap64(x) & 2;
120 }
121 long long test_S64_0_240(long long x) {
122 return (long long)__builtin_bswap64(x) & 240;
123 }
124 long long test_S64_0_255(long long x) {
125 return (long long)__builtin_bswap64(x) & 255;
126 }
127 long long test_S64_7_1(long long x) {
128 return ((long long)__builtin_bswap64(x) >> 7) & 1;
129 }
130 long long test_S64_8_1(long long x) {
131 return ((long long)__builtin_bswap64(x) >> 8) & 1;
132 }
133 long long test_S64_8_240(long long x) {
134 return ((long long)__builtin_bswap64(x) >> 56) & 240;
135 }
136 long long test_S64_8_255(long long x) {
137 return ((long long)__builtin_bswap64(x) >> 8) & 255;
138 }
139 long long test_S64_9_1(long long x) {
140 return ((long long)__builtin_bswap64(x) >> 9) & 1;
141 }
142 long long test_S64_31_1(long long x) {
143 return ((long long)__builtin_bswap64(x) >> 31) & 1;
144 }
145 long long test_S64_32_1(long long x) {
146 return ((long long)__builtin_bswap64(x) >> 32) & 1;
147 }
148 long long test_S64_32_240(long long x) {
149 return ((long long)__builtin_bswap64(x) >> 32) & 240;
150 }
151 long long test_S64_32_255(long long x) {
152 return ((long long)__builtin_bswap64(x) >> 32) & 255;
153 }
154 long long test_S64_33_1(long long x) {
155 return ((long long)__builtin_bswap64(x) >> 33) & 1;
156 }
157 long long test_S64_48_1(long long x) {
158 return ((long long)__builtin_bswap64(x) >> 48) & 1;
159 }
160 long long test_S64_48_240(long long x) {
161 return ((long long)__builtin_bswap64(x) >> 48) & 240;
162 }
163 long long test_S64_48_255(long long x) {
164 return ((long long)__builtin_bswap64(x) >> 48) & 255;
165 }
166 long long test_S64_56_1(long long x) {
167 return ((long long)__builtin_bswap64(x) >> 56) & 1;
168 }
169 long long test_S64_56_240(long long x) {
170 return ((long long)__builtin_bswap64(x) >> 56) & 240;
171 }
172 long long test_S64_56_255(long long x) {
173 return ((long long)__builtin_bswap64(x) >> 56) & 255;
174 }
175 long long test_S64_57_1(long long x) {
176 return ((long long)__builtin_bswap64(x) >> 57) & 1;
177 }
178 long long test_S64_63_1(long long x) {
179 return ((long long)__builtin_bswap64(x) >> 63) & 1;
180 }
181
182 unsigned long long test_u64_56_255(unsigned long long x) {
183 return (__builtin_bswap64(x) >> 56) & 255;
184 }
185
186 short test_s16_0_1(short x) {
187 return __builtin_bswap16(x) & 1;
188 }
189 short test_s16_0_240(short x) {
190 return __builtin_bswap16(x) & 240;
191 }
192 short test_s16_0_255(short x) {
193 return __builtin_bswap16(x) & 255;
194 }
195 short test_s16_1_1(short x) {
196 return (__builtin_bswap16(x) >> 1) & 1;
197 }
198 short test_s16_7_1(short x) {
199 return (__builtin_bswap16(x) >> 7) & 1;
200 }
201 short test_s16_8_1(short x) {
202 return (__builtin_bswap16(x) >> 8) & 1;
203 }
204 short test_s16_8_240(short x) {
205 return (__builtin_bswap16(x) >> 8) & 240;
206 }
207 short test_s16_8_255(short x) {
208 return (__builtin_bswap16(x) >> 8) & 255;
209 }
210 short test_s16_9_1(short x) {
211 return (__builtin_bswap16(x) >> 9) & 1;
212 }
213 short test_s16_15_1(short x) {
214 return (__builtin_bswap16(x) >> 15) & 1;
215 }
216
217 short test_S16_0_1(short x) {
218 return (short)__builtin_bswap16(x) & 1;
219 }
220 short test_S16_0_240(short x) {
221 return (short)__builtin_bswap16(x) & 240;
222 }
223 short test_S16_0_255(short x) {
224 return (short)__builtin_bswap16(x) & 255;
225 }
226 short test_S16_1_1(short x) {
227 return ((short)__builtin_bswap16(x) >> 1) & 1;
228 }
229 short test_S16_7_1(short x) {
230 return ((short)__builtin_bswap16(x) >> 7) & 1;
231 }
232 short test_S16_8_1(short x) {
233 return ((short)__builtin_bswap16(x) >> 8) & 1;
234 }
235 short test_S16_8_240(short x) {
236 return ((short)__builtin_bswap16(x) >> 8) & 240;
237 }
238 short test_S16_8_255(short x) {
239 return ((short)__builtin_bswap16(x) >> 8) & 255;
240 }
241 short test_S16_9_1(short x) {
242 return ((short)__builtin_bswap16(x) >> 9) & 1;
243 }
244 short test_S16_15_1(short x) {
245 return ((short)__builtin_bswap16(x) >> 15) & 1;
246 }
247
248 unsigned short test_u16_8_255(unsigned short x) {
249 return (__builtin_bswap16(x) >> 8) & 255;
250 }
251
252
253 /* Shifts only */
254 int test_s32_24(int x) {
255 return __builtin_bswap32(x) >> 24;
256 }
257 int test_s32_25(int x) {
258 return __builtin_bswap32(x) >> 25;
259 }
260 int test_s32_30(int x) {
261 return __builtin_bswap32(x) >> 30;
262 }
263 int test_s32_31(int x) {
264 return __builtin_bswap32(x) >> 31;
265 }
266
267 unsigned int test_u32_24(unsigned int x) {
268 return __builtin_bswap32(x) >> 24;
269 }
270 unsigned int test_u32_25(unsigned int x) {
271 return __builtin_bswap32(x) >> 25;
272 }
273 unsigned int test_u32_30(unsigned int x) {
274 return __builtin_bswap32(x) >> 30;
275 }
276 unsigned int test_u32_31(unsigned int x) {
277 return __builtin_bswap32(x) >> 31;
278 }
279
280 long long test_s64_56(long long x) {
281 return __builtin_bswap64(x) >> 56;
282 }
283 long long test_s64_57(long long x) {
284 return __builtin_bswap64(x) >> 57;
285 }
286 long long test_s64_62(long long x) {
287 return __builtin_bswap64(x) >> 62;
288 }
289 long long test_s64_63(long long x) {
290 return __builtin_bswap64(x) >> 63;
291 }
292
293 unsigned long long test_u64_56(unsigned long long x) {
294 return __builtin_bswap64(x) >> 56;
295 }
296 unsigned long long test_u64_57(unsigned long long x) {
297 return __builtin_bswap64(x) >> 57;
298 }
299 unsigned long long test_u64_62(unsigned long long x) {
300 return __builtin_bswap64(x) >> 62;
301 }
302 unsigned long long test_u64_63(unsigned long long x) {
303 return __builtin_bswap64(x) >> 63;
304 }
305
306 short test_s16_8(short x) {
307 return __builtin_bswap16(x) >> 8;
308 }
309 short test_s16_9(short x) {
310 return __builtin_bswap16(x) >> 9;
311 }
312 short test_s16_14(short x) {
313 return __builtin_bswap16(x) >> 14;
314 }
315 short test_s16_15(short x) {
316 return __builtin_bswap16(x) >> 15;
317 }
318
319 unsigned short test_u16_8(unsigned short x) {
320 return __builtin_bswap16(x) >> 8;
321 }
322 unsigned short test_u16_9(unsigned short x) {
323 return __builtin_bswap16(x) >> 9;
324 }
325 unsigned short test_u16_14(unsigned short x) {
326 return __builtin_bswap16(x) >> 14;
327 }
328 unsigned short test_u16_15(unsigned short x) {
329 return __builtin_bswap16(x) >> 15;
330 }
331
332 /* { dg-final { scan-tree-dump-not "__builtin_bswap" "optimized" } } */
333