1 /* { dg-do compile } */
2 /* { dg-require-effective-target stdint_types } */
3 /* { dg-options "-O2 -fdump-tree-bswap" } */
7 #define __const_swab32(x) ((uint32_t)( \
8 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
9 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
10 (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
11 (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
13 #define __const_swab64(x) ((uint64_t)( \
14 (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
15 (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
16 (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
17 (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
18 (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
19 (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
20 (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
21 (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
23 /* This byte swap implementation is used by the Linux kernel and the
27 swap32_a (uint32_t in
)
29 return __const_swab32 (in
);
35 return __const_swab64 (in
);
38 /* The OpenSSH byte swap implementation. */
40 swap32_b (uint32_t in
)
44 a
= (in
<< 16) | (in
>> 16);
45 a
= ((a
& 0x00ff00ff) << 8) | ((a
& 0xff00ff00) >> 8);
50 /* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
51 /* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 1 "bswap" } } */
52 /* { dg-final { cleanup-tree-dump "bswap" } } */