1 /* { dg-do compile } */
2 /* { dg-skip-if "No __builtin_cbrt" { powerpc*-*-darwin* } } */
3 /* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt -fno-ident" } */
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 unsigned i;
40
41 for (i = 0; i < NVALS; i++)
42 {
43 if (convert_it_1 (values[i]) !=
44 __builtin_powi (values[i], 3) * __builtin_powi (cbrt (values[i]), 1))
45 abort ();
46 if (convert_it_2 (values[i]) !=
47 __builtin_powi (values[i], 3) * __builtin_powi (cbrt (values[i]), 2))
48 abort ();
49 if (convert_it_3 (values[i]) !=
50 __builtin_powi (values[i], -3) * __builtin_powi (cbrt (values[i]), 2))
51 abort ();
52 if (convert_it_4 (values[i]) !=
53 __builtin_powi (values[i], -3) * __builtin_powi (cbrt (values[i]), 1))
54 abort ();
55 }
56
57 return 0;
58 }
59
60
61 /* { dg-final { scan-assembler-times "cbrt" 5 { target powerpc*-*-* } } } */
62 /* { dg-final { scan-assembler-not "bl\[\\. \]+pow" { target powerpc*-*-* } } } */
63