PR c/56980
[official-gcc.git] / gcc / testsuite / gcc.dg / pr43280.c
blobdfb369b5de1839b9eea99160afd53e542f7ed2aa
1 /* { dg-do run } */
2 /* { dg-require-effective-target stdint_types } */
3 /* { dg-options "-O2" } */
5 #include <stdint.h>
7 extern void abort (void);
9 uint64_t __attribute__((noinline))
10 byteswap64(uint64_t x)
12 uint32_t a = x >> 32;
13 uint32_t b = (uint32_t) x;
14 return ((uint64_t) ((((((b)) >> (8)) | (((b)) << (32 - (8)))) & 0xff00ff00L)
15 | (((((b)) << (8)) | (((b)) >> (32 - (8)))) & 0x00ff00ffL)) << 32)
16 | (uint64_t) ((((((a)) >> (8)) | (((a)) << (32 - (8)))) & 0xff00ff00L)
17 | (((((a)) << (8)) | (((a)) >> (32 - (8)))) & 0x00ff00ffL));
20 int
21 main ()
23 uint64_t in = (uint64_t)0x01020304 << 32 | 0x05060708;
24 uint64_t cmp = (uint64_t)0x08070605 << 32 | 0x04030201;
26 if (cmp != byteswap64 (in))
27 abort ();
29 return 0;