(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
clone3.c
       1  /* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
       2  /* { dg-options "-mdejagnu-cpu=power8 -O2" } */
       3  /* { dg-require-effective-target powerpc_pcrel } */
       4  /* { dg-require-effective-target ppc_cpu_supports_hw } */
       5  
       6  /* Power9 (aka, ISA 3.0) has a MODSD instruction to do modulus, while Power8
       7     (aka, ISA 2.07) has to do modulus with divide and multiply.  Make sure
       8     both clone functions are generated.
       9  
      10     FUTURE has pc-relative instructions to access static values, while earlier
      11     systems used TOC addressing.
      12  
      13     Restrict ourselves to Linux, since IFUNC might not be supported in other
      14     operating systems.  */
      15  
      16  static long s;
      17  long *p = &s;
      18  
      19  __attribute__((target_clones("cpu=power10,cpu=power9,default")))
      20  long mod_func (long a, long b)
      21  {
      22    return (a % b) + s;
      23  }
      24  
      25  long mod_func_or (long a, long b, long c)
      26  {
      27    return mod_func (a, b) | c;
      28  }
      29  
      30  /* { dg-final { scan-assembler-times {\mdivd\M}  1 } } */
      31  /* { dg-final { scan-assembler-times {\mmulld\M} 1 } } */
      32  /* { dg-final { scan-assembler-times {\mmodsd\M} 2 } } */
      33  /* { dg-final { scan-assembler-times {\mpld\M}   1 } } */