[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr46728-15.c
blobb4c9660626962d7f603aace62ca3a3141aaf4bf7
1 /* { dg-do run } */
2 /* { dg-skip-if "-mpowerpc-gpopt not supported" { powerpc*-*-darwin* } } */
3 /* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
5 #include <math.h>
7 extern void abort (void);
9 #define NVALS 6
11 static double
12 convert_it_1 (double x)
14 return pow (x, 10.0 / 3.0);
17 static double
18 convert_it_2 (double x)
20 return pow (x, 11.0 / 3.0);
23 static double
24 convert_it_3 (double x)
26 return pow (x, -7.0 / 3.0);
29 static double
30 convert_it_4 (double x)
32 return pow (x, -8.0 / 3.0);
35 int
36 main (int argc, char *argv[])
38 double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
39 double PREC = .999999;
40 unsigned i;
42 for (i = 0; i < NVALS; i++)
44 volatile double x, y;
46 x = __builtin_powi (values[i], 3);
47 y = __builtin_powi (cbrt (values[i]), 1);
48 if (fabs (convert_it_1 (values[i]) / (x * y)) < PREC)
49 abort ();
51 x = __builtin_powi (values[i], 3);
52 y = __builtin_powi (cbrt (values[i]), 2);
53 if (fabs (convert_it_2 (values[i]) / (x * y)) < PREC)
54 abort ();
56 x = __builtin_powi (values[i], -3);
57 y = __builtin_powi (cbrt (values[i]), 2);
58 if (fabs (convert_it_3 (values[i]) / (x * y)) < PREC)
59 abort ();
61 x = __builtin_powi (values[i], -3);
62 y = __builtin_powi (cbrt (values[i]), 1);
63 if (fabs (convert_it_4 (values[i]) / (x * y)) < PREC)
64 abort ();
67 return 0;