(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
builtin-bswap-6a.c
       1  /* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */
       2  /* { dg-require-effective-target stdint_types } */
       3  /* { dg-options "-O2 -fdump-rtl-combine" } */
       4  /* { dg-additional-options "-march=z900" { target s390*-*-* } } */
       5  
       6  /* The test is similiar to builtin-bswap-6.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_bswap32(X)
      14  
      15  int foo1 (uint32_t a)
      16  {
      17    if (BS (a) == 0xA0000)
      18      return 1;
      19    return 2;
      20  }
      21  
      22  int foo2 (uint32_t a)
      23  {
      24    if (BS (a) != 0xA0000)
      25      return 1;
      26    return 2;
      27  }
      28  
      29  int foo3 (uint32_t a, uint32_t b)
      30  {
      31    if (BS (a) == BS (b))
      32      return 1;
      33    return 2;
      34  }
      35  
      36  int foo4 (uint32_t a, uint32_t b)
      37  {
      38    if (BS (a) != BS (b))
      39      return 1;
      40    return 2;
      41  }
      42  
      43  /* { dg-final { scan-rtl-dump-not "bswapsi" "combine" } } */