(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
sh/
pr53568-1.c
       1  /* Check that the bswap32 pattern is generated as swap.b and swap.w
       2     instructions.  */
       3  /* { dg-do compile }  */
       4  /* { dg-options "-O2" } */
       5  /* { dg-final { scan-assembler-times "swap.w" 7 } } */
       6  /* { dg-final { scan-assembler-times "swap.b" 16 } } */
       7  /* { dg-final { scan-assembler-times "extu.w" 2 } } */
       8  /* { dg-final { scan-assembler-times "mov" 1 } } */
       9  /* { dg-final { scan-assembler-not "{shll8|shlr8|shld|shad}" } } */
      10  
      11  int
      12  test_func_00 (int a)
      13  {
      14    /* 1x swap.w
      15       2x swap.b  */
      16    return __builtin_bswap32 (a);
      17  }
      18  
      19  unsigned int
      20  test_func_01 (unsigned int a)
      21  {
      22    /* 1x swap.w
      23       2x swap.b  */
      24    return __builtin_bswap32 (a);
      25  }
      26  
      27  int
      28  test_func_02 (int a)
      29  {
      30    /* 1x swap.w
      31       2x swap.b  */
      32    return (((a >> 0) & 0xFF) << 24)
      33  	 | (((a >> 8) & 0xFF) << 16)
      34  	 | (((a >> 16) & 0xFF) << 8)
      35  	 | (((a >> 24) & 0xFF) << 0);
      36  }
      37  
      38  unsigned int
      39  test_func_03 (unsigned int a)
      40  {
      41    /* 1x swap.w
      42       2x swap.b  */
      43    return (((a >> 0) & 0xFF) << 24)
      44  	 | (((a >> 8) & 0xFF) << 16)
      45  	 | (((a >> 16) & 0xFF) << 8)
      46  	 | (((a >> 24) & 0xFF) << 0);
      47  }
      48  
      49  int
      50  test_func_04 (int a)
      51  {
      52    /* 1x swap.b
      53       1x extu.w  */
      54    return __builtin_bswap32 (a) >> 16;
      55  }
      56  
      57  unsigned short
      58  test_func_05 (unsigned short a)
      59  {
      60    /* 1x swap.b
      61       1x extu.w  */
      62    return __builtin_bswap32 (a) >> 16;
      63  }
      64  
      65  long long
      66  test_func_06 (long long a)
      67  {
      68    /* 2x swap.w
      69       4x swap.b  */
      70    return __builtin_bswap64 (a);
      71  }
      72  
      73  long long
      74  test_func_07 (long long a)
      75  {
      76    /* 1x swap.w
      77       2x swap.b
      78       1x mov #0,Rn  */
      79    return __builtin_bswap64 (a) >> 32;
      80  }
      81