From: Bill Schmidt Date: Fri, 27 May 2011 19:39:07 +0000 (+0000) Subject: re PR tree-optimization/46728 (GCC does not generate fmadd for pow (x, 0.75)+y on... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=226855f0608af61a273c095fce991bd5fa9b32b3;p=gcc.git re PR tree-optimization/46728 (GCC does not generate fmadd for pow (x, 0.75)+y on powerpc) 2011-05-27 Bill Schmidt 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 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c97a9f07df..a8be7cdc300 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,23 @@ +2011-05-27 Bill Schmidt + + 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 * 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 00000000000..c383e878c5d --- /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 + +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 00000000000..66c6e2cabec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr46728-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -lm" } */ + +#include + +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 00000000000..7496976205f --- /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 + +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 00000000000..16336243a30 --- /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 + +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 00000000000..84833c84a0e --- /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 + +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 00000000000..0dd0f7571a3 --- /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 + +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 00000000000..71015a942c0 --- /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 + +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 00000000000..d5fc83ba2d9 --- /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 + +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 00000000000..0586e29013f --- /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 + +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 00000000000..d9488e3b7a3 --- /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 00000000000..abf92491f95 --- /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 + +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 00000000000..a00f7940a42 --- /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 + +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 00000000000..95d8fbe89ea --- /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 + +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 00000000000..a380d522521 --- /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 + +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 00000000000..873596cff37 --- /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 + +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 00000000000..6480c7df9ba --- /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 + +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*-*-* } } } */