(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
arm/
sdiv_costs_1.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O3" } */
       3  /* { dg-require-effective-target arm_arch_v8a_ok } */
       4  /* { dg-add-options arm_arch_v8a } */
       5  
       6  /* Both sdiv and udiv can be used here, so prefer udiv.  */
       7  int f1 (unsigned char *p)
       8  {
       9    return 100 / p[1];
      10  }
      11  
      12  int f2 (unsigned char *p, unsigned short x)
      13  {
      14    return x / p[0];
      15  }
      16  
      17  int f3 (unsigned char *p, int x)
      18  {
      19    x &= 0x7fffffff;
      20    return x / p[0];
      21  }
      22  
      23  int f5 (unsigned char *p, unsigned short x)
      24  {
      25    return x % p[0];
      26  }
      27  
      28  /* This should only generate signed divisions.  */
      29  int f4 (unsigned char *p)
      30  {
      31    return -100 / p[1];
      32  }
      33  
      34  int f6 (unsigned char *p, short x)
      35  {
      36    return x % p[0];
      37  }
      38  
      39  /* { dg-final { scan-assembler-times "udiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 4 } } */
      40  /* { dg-final { scan-assembler-times "sdiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 2 } } */