(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
riscv/
zbs-bexti.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-march=rv64gc_zbs -mabi=lp64" } */
       3  /* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */
       4  
       5  /* bexti */
       6  #define BIT_NO  21
       7  
       8  long bexti64_1(long a, char bitno)
       9  {
      10    return (a & (1UL << BIT_NO)) ? 1 : 0;
      11  }
      12  
      13  long bexti64_2(long a, char bitno)
      14  {
      15    return (a & (1UL << BIT_NO)) ? 0 : 1;
      16  }
      17  
      18  long bexti64_3(long a, char bitno)
      19  {
      20    return (a & (1UL << BIT_NO)) ? 0 : -1;
      21  }
      22  
      23  long bexti64_4(long a, char bitno)
      24  {
      25    return (a & (1UL << BIT_NO)) ? -1 : 0;
      26  }
      27  
      28  /* { dg-final { scan-assembler-times "bexti\t" 4 } } */
      29  /* { dg-final { scan-assembler-times "xori\t" 1 } } */
      30  /* { dg-final { scan-assembler-times "addi\t" 1 } } */
      31  /* { dg-final { scan-assembler-times "neg\t" 1 } } */