1 /* { dg-do compile } */
2 /* { dg-require-effective-target bswap64 } */
3 /* { dg-require-effective-target stdint_types } */
4 /* { dg-options "-O2 -fdump-tree-bswap" } */
7 #define __const_swab64(x) ((uint64_t)( \
8 (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
9 (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
10 (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
11 (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
12 (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
13 (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
14 (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
15 (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
18 /* This byte swap implementation is used by the Linux kernel and the
24 return __const_swab64 (in
);
27 /* This variant is currently used by libgcc. The difference is that
28 the bswap source and destination have a signed integer type which
29 requires a slightly higher search depth in order to dive through
32 typedef int DItype
__attribute__ ((mode (DI
)));
36 return ((((u
) & 0xff00000000000000ull
) >> 56)
37 | (((u
) & 0x00ff000000000000ull
) >> 40)
38 | (((u
) & 0x0000ff0000000000ull
) >> 24)
39 | (((u
) & 0x000000ff00000000ull
) >> 8)
40 | (((u
) & 0x00000000ff000000ull
) << 8)
41 | (((u
) & 0x0000000000ff0000ull
) << 24)
42 | (((u
) & 0x000000000000ff00ull
) << 40)
43 | (((u
) & 0x00000000000000ffull
) << 56));
46 /* The OpenSSL variant. */
52 uint32_t b
= (uint32_t) x
;
53 return ((uint64_t) ((((((b
)) >> (8)) | (((b
)) << (32 - (8)))) & 0xff00ff00L
)
54 | (((((b
)) << (8)) | (((b
)) >> (32 - (8)))) & 0x00ff00ffL
)) << 32)
55 | (uint64_t) ((((((a
)) >> (8)) | (((a
)) << (32 - (8)))) & 0xff00ff00L
)
56 | (((((a
)) << (8)) | (((a
)) >> (32 - (8)))) & 0x00ff00ffL
));
60 /* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 3 "bswap" } } */
61 /* { dg-final { cleanup-tree-dump "bswap" } } */