Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr46728-14.c
blob5affff13bdb6c7f8cc5ba1f0d0b3c30507397e1b
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, 1.5);
17 static double
18 convert_it_2 (double x)
20 return pow (x, 2.5);
23 static double
24 convert_it_3 (double x)
26 return pow (x, -0.5);
29 static double
30 convert_it_4 (double x)
32 return pow (x, 10.5);
35 static double
36 convert_it_5 (double x)
38 return pow (x, -3.5);
41 int
42 main (int argc, char *argv[])
44 double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
45 double PREC = .999999;
46 unsigned i;
48 for (i = 0; i < NVALS; i++)
50 volatile double x, y;
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 ();
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 ();
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 ();
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 ();
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 ();
78 return 0;