1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-options "-mvsx -O2" } */
3 /* { dg-require-effective-target powerpc_p9vector_ok } */
4 /* { dg-require-effective-target ppc_cpu_supports_hw } */
5 
6 #include <stddef.h>
7 #include <stdlib.h>
8 
9 /* Power9 (aka, ISA 3.0) has a MODSD instruction to do modulus, while Power8
10    (aka, ISA 2.07) has to do modulus with divide and multiply.  Make sure that
11    the basic support for target_clones runs.
12 
13    Restrict ourselves to Linux, since IFUNC might not be supported in other
14    operating systems.  */
15 
16 __attribute__((__target_clones__("cpu=power9,default")))
mod_func(long a,long b)17 long mod_func (long a, long b)
18 {
19   return a % b;
20 }
21 
22 #define X 53L
23 #define Y 7L
24 int
main(void)25 main (void)
26 {
27   if (mod_func (X, Y) != (X % Y))
28     abort ();
29 
30   return 0;
31 }
32