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
12 convert_it_1 (double x)
13 {
14 return pow (x, 1.5);
15 }
16
17 static double
18 convert_it_2 (double x)
19 {
20 return pow (x, 2.5);
21 }
22
23 static double
24 convert_it_3 (double x)
25 {
26 return pow (x, -0.5);
27 }
28
29 static double
30 convert_it_4 (double x)
31 {
32 return pow (x, 10.5);
33 }
34
35 static double
36 convert_it_5 (double x)
37 {
38 return pow (x, -3.5);
39 }
40
41 int
42 main (int argc, char *argv[])
43 {
44 double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
45 double PREC = .999999;
46 unsigned i;
47
48 for (i = 0; i < NVALS; i++)
49 {
50 volatile double x, y;
51
52 x = sqrt (values[i]);
53 y = __builtin_powi (values[i], 1);
54 if (fabs (convert_it_1 (values[i]) / (x * y)) < PREC)
55 abort ();
56
57 x = sqrt (values[i]);
58 y = __builtin_powi (values[i], 2);
59 if (fabs (convert_it_2 (values[i]) / (x * y)) < PREC)
60 abort ();
61
62 x = sqrt (values[i]);
63 y = __builtin_powi (values[i], -1);
64 if (fabs (convert_it_3 (values[i]) / (x * y)) < PREC)
65 abort ();
66
67 x = sqrt (values[i]);
68 y = __builtin_powi (values[i], 10);
69 if (fabs (convert_it_4 (values[i]) / (x * y)) < PREC)
70 abort ();
71
72 x = sqrt (values[i]);
73 y = __builtin_powi (values[i], -4);
74 if (fabs (convert_it_5 (values[i]) / (x * y)) < PREC)
75 abort ();
76 }
77
78 return 0;
79 }