aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2011-05-27 19:39:07 +0000
committerWilliam Schmidt <wschmidt@gcc.gnu.org>2011-05-27 19:39:07 +0000
commit226855f0608af61a273c095fce991bd5fa9b32b3 (patch)
tree3358e2cb793e8d4dccef207dc73d80aa9263fe8a
parenta47d328ff345b05eb6fec4683ac04ac939064bfc (diff)
downloadgcc-226855f0608af61a273c095fce991bd5fa9b32b3.zip
gcc-226855f0608af61a273c095fce991bd5fa9b32b3.tar.gz
gcc-226855f0608af61a273c095fce991bd5fa9b32b3.tar.bz2
re PR tree-optimization/46728 (GCC does not generate fmadd for pow (x, 0.75)+y on powerpc)
2011-05-27 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/46728 * gcc.target/powerpc/pr46728-1.c: New. * gcc.target/powerpc/pr46728-2.c: New. * gcc.target/powerpc/pr46728-3.c: New. * gcc.target/powerpc/pr46728-4.c: New. * gcc.target/powerpc/pr46728-5.c: New. * gcc.dg/pr46728-6.c: New. * gcc.target/powerpc/pr46728-7.c: New. * gcc.target/powerpc/pr46728-8.c: New. * gcc.dg/pr46728-9.c: New. * gcc.target/powerpc/pr46728-10.c: New. * gcc.target/powerpc/pr46728-11.c: New. * gcc.dg/pr46728-12.c: New. * gcc.target/powerpc/pr46728-13.c: New. * gcc.target/powerpc/pr46728-14.c: New. * gcc.target/powerpc/pr46728-15.c: New. * gcc.target/powerpc/pr46728-16.c: New. From-SVN: r174358
-rw-r--r--gcc/testsuite/ChangeLog20
-rw-r--r--gcc/testsuite/gcc.dg/pr46728-12.c28
-rw-r--r--gcc/testsuite/gcc.dg/pr46728-6.c21
-rw-r--r--gcc/testsuite/gcc.dg/pr46728-9.c29
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-1.c31
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-10.c28
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-11.c34
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-13.c27
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-14.c78
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-15.c67
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-16.c10
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-2.c31
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-3.c31
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-4.c31
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-5.c31
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-7.c57
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr46728-8.c61
17 files changed, 615 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4c97a9f..a8be7cd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,23 @@
+2011-05-27 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/46728
+ * gcc.target/powerpc/pr46728-1.c: New.
+ * gcc.target/powerpc/pr46728-2.c: New.
+ * gcc.target/powerpc/pr46728-3.c: New.
+ * gcc.target/powerpc/pr46728-4.c: New.
+ * gcc.target/powerpc/pr46728-5.c: New.
+ * gcc.dg/pr46728-6.c: New.
+ * gcc.target/powerpc/pr46728-7.c: New.
+ * gcc.target/powerpc/pr46728-8.c: New.
+ * gcc.dg/pr46728-9.c: New.
+ * gcc.target/powerpc/pr46728-10.c: New.
+ * gcc.target/powerpc/pr46728-11.c: New.
+ * gcc.dg/pr46728-12.c: New.
+ * gcc.target/powerpc/pr46728-13.c: New.
+ * gcc.target/powerpc/pr46728-14.c: New.
+ * gcc.target/powerpc/pr46728-15.c: New.
+ * gcc.target/powerpc/pr46728-16.c: New.
+
2011-05-27 Jason Merrill <jason@redhat.com>
* g++.dg/abi/mangle47.C: New.
diff --git a/gcc/testsuite/gcc.dg/pr46728-12.c b/gcc/testsuite/gcc.dg/pr46728-12.c
new file mode 100644
index 0000000..c383e87
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46728-12.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 1.0 / 3.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 729.0, 64.0, .0008797 };
+ double PREC = 0.999999;
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (fabs (convert_it (values[i]) / cbrt (values[i])) < PREC)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr46728-6.c b/gcc/testsuite/gcc.dg/pr46728-6.c
new file mode 100644
index 0000000..66c6e2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46728-6.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -lm" } */
+
+#include <math.h>
+
+int
+main (int argc, char *argv[])
+{
+ volatile double result;
+
+ result = pow (-0.0, 3.0);
+ result = pow (26.47, -2.0);
+ result = pow (0.0, 0.0);
+ result = pow (22.3, 1.0);
+ result = pow (33.2, -1.0);
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-not "pow" } } */
diff --git a/gcc/testsuite/gcc.dg/pr46728-9.c b/gcc/testsuite/gcc.dg/pr46728-9.c
new file mode 100644
index 0000000..7496976
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46728-9.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ double PREC = 0.999999;
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (fabs (convert_it (values[i]) / sqrt (values[i])) < PREC)
+ abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-1.c b/gcc/testsuite/gcc.target/powerpc/pr46728-1.c
new file mode 100644
index 0000000..1633624
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-1.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != sqrt (values[i]))
+ abort ();
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "fsqrt" 2 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-10.c b/gcc/testsuite/gcc.target/powerpc/pr46728-10.c
new file mode 100644
index 0000000..84833c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-10.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.25);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != sqrt (sqrt (values[i])))
+ abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-11.c b/gcc/testsuite/gcc.target/powerpc/pr46728-11.c
new file mode 100644
index 0000000..0dd0f75
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-11.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.75);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ double PREC = 0.999999;
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ {
+ volatile double x, y;
+ x = sqrt (values[i]);
+ y = sqrt (sqrt (values[i]));
+
+ if (fabs (convert_it (values[i]) / (x * y)) < PREC)
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-13.c b/gcc/testsuite/gcc.target/powerpc/pr46728-13.c
new file mode 100644
index 0000000..71015a9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-13.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 1.0 / 6.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 729.0, 64.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != cbrt (sqrt (values[i])))
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-14.c b/gcc/testsuite/gcc.target/powerpc/pr46728-14.c
new file mode 100644
index 0000000..d5fc83b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-14.c
@@ -0,0 +1,78 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it_1 (double x)
+{
+ return pow (x, 1.5);
+}
+
+static double
+convert_it_2 (double x)
+{
+ return pow (x, 2.5);
+}
+
+static double
+convert_it_3 (double x)
+{
+ return pow (x, -0.5);
+}
+
+static double
+convert_it_4 (double x)
+{
+ return pow (x, 10.5);
+}
+
+static double
+convert_it_5 (double x)
+{
+ return pow (x, -3.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ double PREC = .999999;
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ {
+ volatile double x, y;
+
+ x = sqrt (values[i]);
+ y = __builtin_powi (values[i], 1);
+ if (fabs (convert_it_1 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = sqrt (values[i]);
+ y = __builtin_powi (values[i], 2);
+ if (fabs (convert_it_2 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = sqrt (values[i]);
+ y = __builtin_powi (values[i], -1);
+ if (fabs (convert_it_3 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = sqrt (values[i]);
+ y = __builtin_powi (values[i], 10);
+ if (fabs (convert_it_4 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = sqrt (values[i]);
+ y = __builtin_powi (values[i], -4);
+ if (fabs (convert_it_5 (values[i]) / (x * y)) < PREC)
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-15.c b/gcc/testsuite/gcc.target/powerpc/pr46728-15.c
new file mode 100644
index 0000000..0586e29
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-15.c
@@ -0,0 +1,67 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it_1 (double x)
+{
+ return pow (x, 10.0 / 3.0);
+}
+
+static double
+convert_it_2 (double x)
+{
+ return pow (x, 11.0 / 3.0);
+}
+
+static double
+convert_it_3 (double x)
+{
+ return pow (x, -7.0 / 3.0);
+}
+
+static double
+convert_it_4 (double x)
+{
+ return pow (x, -8.0 / 3.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ double PREC = .999999;
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ {
+ volatile double x, y;
+
+ x = __builtin_powi (values[i], 3);
+ y = __builtin_powi (cbrt (values[i]), 1);
+ if (fabs (convert_it_1 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = __builtin_powi (values[i], 3);
+ y = __builtin_powi (cbrt (values[i]), 2);
+ if (fabs (convert_it_2 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = __builtin_powi (values[i], -3);
+ y = __builtin_powi (cbrt (values[i]), 2);
+ if (fabs (convert_it_3 (values[i]) / (x * y)) < PREC)
+ abort ();
+
+ x = __builtin_powi (values[i], -3);
+ y = __builtin_powi (cbrt (values[i]), 1);
+ if (fabs (convert_it_4 (values[i]) / (x * y)) < PREC)
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-16.c b/gcc/testsuite/gcc.target/powerpc/pr46728-16.c
new file mode 100644
index 0000000..d9488e3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-16.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -mcpu=power6" } */
+
+double foo (double x, double y)
+{
+ return __builtin_pow (x, 0.75) + y;
+}
+
+
+/* { dg-final { scan-assembler "fmadd" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-2.c b/gcc/testsuite/gcc.target/powerpc/pr46728-2.c
new file mode 100644
index 0000000..abf9249
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-2.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.25);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != sqrt (sqrt (values[i])))
+ abort ();
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "fsqrt" 4 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-3.c b/gcc/testsuite/gcc.target/powerpc/pr46728-3.c
new file mode 100644
index 0000000..a00f794
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-3.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 0.75);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != sqrt(values[i]) * sqrt (sqrt (values[i])))
+ abort ();
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "sqrt" 4 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-4.c b/gcc/testsuite/gcc.target/powerpc/pr46728-4.c
new file mode 100644
index 0000000..95d8fbe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-4.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 1.0 / 3.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 729.0, 64.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != cbrt (values[i]))
+ abort ();
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "cbrt" 2 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-5.c b/gcc/testsuite/gcc.target/powerpc/pr46728-5.c
new file mode 100644
index 0000000..a380d52
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-5.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it (double x)
+{
+ return pow (x, 1.0 / 6.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 729.0, 64.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ if (convert_it (values[i]) != cbrt (sqrt (values[i])))
+ abort ();
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "cbrt" 2 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not " pow " { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-7.c b/gcc/testsuite/gcc.target/powerpc/pr46728-7.c
new file mode 100644
index 0000000..873596c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-7.c
@@ -0,0 +1,57 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it_1 (double x)
+{
+ return pow (x, 1.5);
+}
+
+static double
+convert_it_2 (double x)
+{
+ return pow (x, 2.5);
+}
+
+static double
+convert_it_3 (double x)
+{
+ return pow (x, -0.5);
+}
+
+static double
+convert_it_4 (double x)
+{
+ return pow (x, 10.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ {
+ if (convert_it_1 (values[i]) != sqrt (values[i]) * __builtin_powi (values[i], 1))
+ abort ();
+ if (convert_it_2 (values[i]) != sqrt (values[i]) * __builtin_powi (values[i], 2))
+ abort ();
+ if (convert_it_3 (values[i]) != sqrt (values[i]) * __builtin_powi (values[i], -1))
+ abort ();
+ if (convert_it_4 (values[i]) != sqrt (values[i]) * __builtin_powi (values[i], 10))
+ abort ();
+ }
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "sqrt" 5 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr46728-8.c b/gcc/testsuite/gcc.target/powerpc/pr46728-8.c
new file mode 100644
index 0000000..6480c7d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr46728-8.c
@@ -0,0 +1,61 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm -mpowerpc-gpopt" } */
+
+#include <math.h>
+
+extern void abort (void);
+
+#define NVALS 6
+
+static double
+convert_it_1 (double x)
+{
+ return pow (x, 10.0 / 3.0);
+}
+
+static double
+convert_it_2 (double x)
+{
+ return pow (x, 11.0 / 3.0);
+}
+
+static double
+convert_it_3 (double x)
+{
+ return pow (x, -7.0 / 3.0);
+}
+
+static double
+convert_it_4 (double x)
+{
+ return pow (x, -8.0 / 3.0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 };
+ unsigned i;
+
+ for (i = 0; i < NVALS; i++)
+ {
+ if (convert_it_1 (values[i]) !=
+ __builtin_powi (values[i], 3) * __builtin_powi (cbrt (values[i]), 1))
+ abort ();
+ if (convert_it_2 (values[i]) !=
+ __builtin_powi (values[i], 3) * __builtin_powi (cbrt (values[i]), 2))
+ abort ();
+ if (convert_it_3 (values[i]) !=
+ __builtin_powi (values[i], -3) * __builtin_powi (cbrt (values[i]), 2))
+ abort ();
+ if (convert_it_4 (values[i]) !=
+ __builtin_powi (values[i], -3) * __builtin_powi (cbrt (values[i]), 1))
+ abort ();
+ }
+
+ return 0;
+}
+
+
+/* { dg-final { scan-assembler-times "cbrt" 5 { target powerpc*-*-* } } } */
+/* { dg-final { scan-assembler-not "pow" { target powerpc*-*-* } } } */