1 /* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */
2 /* { dg-require-effective-target stdint_types } */
3 /* { dg-require-effective-target lp64 } */
4 /* { dg-options "-O2 -fdump-rtl-combine" } */
5 
6 /* The test is similiar to builtin-bswap-7.c but returns 1/2 instead
7    of 0/1 to prevent GCC from calculating the return value with
8    arithmetic instead of a comparison.  This requires the optimization
9    level to be bumped up to -O2 at least for x86_64.  */
10 
11 #include <stdint.h>
12 
13 #define BS(X) __builtin_bswap64(X)
14 
foo1(uint64_t a)15 int foo1 (uint64_t a)
16 {
17   if (BS (a) == 0xA00000000)
18     return 1;
19   return 2;
20 }
21 
foo2(uint64_t a)22 int foo2 (uint64_t a)
23 {
24   if (BS (a) != 0xA00000000)
25     return 1;
26   return 2;
27 }
28 
foo3(uint64_t a,uint64_t b)29 int foo3 (uint64_t a, uint64_t b)
30 {
31   if (BS (a) == BS (b))
32     return 1;
33   return 2;
34 }
35 
foo4(uint64_t a,uint64_t b)36 int foo4 (uint64_t a, uint64_t b)
37 {
38   if (BS (a) != BS (b))
39     return 1;
40   return 2;
41 }
42 
43 /* { dg-final { scan-rtl-dump-not "bswapdi" "combine" } } */
44 /* { dg-final { cleanup-rtl-dump "combine" } } */
45