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" } */
4 
5 #include <math.h>
6 
7 extern void abort (void);
8 
9 #define NVALS 6
10 
11 static double
convert_it_1(double x)12 convert_it_1 (double x)
13 {
14   return pow (x, 10.0 / 3.0);
15 }
16 
17 static double
convert_it_2(double x)18 convert_it_2 (double x)
19 {
20   return pow (x, 11.0 / 3.0);
21 }
22 
23 static double
convert_it_3(double x)24 convert_it_3 (double x)
25 {
26   return pow (x, -7.0 / 3.0);
27 }
28 
29 static double
convert_it_4(double x)30 convert_it_4 (double x)
31 {
32   return pow (x, -8.0 / 3.0);
33 }
34 
35 int
main(int argc,char * argv[])36 main (int argc, char *argv[])
37 {
38   double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
39   double PREC = .999999;
40   unsigned i;
41 
42   for (i = 0; i < NVALS; i++)
43     {
44       volatile double x, y;
45 
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 ();
50 
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 ();
55 
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 ();
60 
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 ();
65     }
66 
67   return 0;
68 }
69