comparison gcc/testsuite/gcc.dg/pr43280.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-do run } */
2 /* { dg-require-effective-target stdint_types } */
3 /* { dg-options "-O2" } */
4
5 #include <stdint.h>
6
7 extern void abort (void);
8
9 uint64_t __attribute__((noinline))
10 byteswap64(uint64_t x)
11 {
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));
18 }
19
20 int
21 main ()
22 {
23 uint64_t in = (uint64_t)0x01020304 << 32 | 0x05060708;
24 uint64_t cmp = (uint64_t)0x08070605 << 32 | 0x04030201;
25
26 if (cmp != byteswap64 (in))
27 abort ();
28
29 return 0;
30 }