public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, testsuite] Additional tests for PR46728 (PR46728 patch 4)
@ 2011-05-25 21:05 William J. Schmidt
  2011-05-26 10:45 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: William J. Schmidt @ 2011-05-25 21:05 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.guenther

Since I'm in process of moving the lowering of pow and powi calls from
expand into gimple, I wrote some tests to improve coverage in this area.
Most of these look for specific code generation patterns in PowerPC
assembly where the existence of a hardware floating square root can be
guaranteed.

This patch is conditional on patch 3 of the PR46728 series; without it,
test pr46728-16.c will fail, since the FMA will not be generated.  All
other tests currently pass.

OK to add to test suite on trunk?

Thanks,
Bill


2011-05-25  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	* 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.

Index: gcc/testsuite/gcc.target/powerpc/pr46728-13.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-13.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-13.c	(revision 0)
@@ -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;
+}
Index: gcc/testsuite/gcc.target/powerpc/pr46728-3.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-3.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-3.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-14.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-14.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-14.c	(revision 0)
@@ -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;
+}
Index: gcc/testsuite/gcc.target/powerpc/pr46728-4.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-4.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-4.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-15.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-15.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-15.c	(revision 0)
@@ -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;
+}
Index: gcc/testsuite/gcc.target/powerpc/pr46728-5.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-5.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-5.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-16.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-16.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-16.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-7.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-7.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-7.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-10.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-10.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-10.c	(revision 0)
@@ -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;
+}
+
Index: gcc/testsuite/gcc.target/powerpc/pr46728-8.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-8.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-8.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-11.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-11.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-11.c	(revision 0)
@@ -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;
+}
Index: gcc/testsuite/gcc.target/powerpc/pr46728-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-1.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-1.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.target/powerpc/pr46728-2.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr46728-2.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-2.c	(revision 0)
@@ -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*-*-* } } } */
Index: gcc/testsuite/gcc.dg/pr46728-9.c
===================================================================
--- gcc/testsuite/gcc.dg/pr46728-9.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr46728-9.c	(revision 0)
@@ -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;
+}
+
Index: gcc/testsuite/gcc.dg/pr46728-12.c
===================================================================
--- gcc/testsuite/gcc.dg/pr46728-12.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr46728-12.c	(revision 0)
@@ -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;
+}
Index: gcc/testsuite/gcc.dg/pr46728-6.c
===================================================================
--- gcc/testsuite/gcc.dg/pr46728-6.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr46728-6.c	(revision 0)
@@ -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" } } */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, testsuite] Additional tests for PR46728 (PR46728 patch 4)
  2011-05-25 21:05 [PATCH, testsuite] Additional tests for PR46728 (PR46728 patch 4) William J. Schmidt
@ 2011-05-26 10:45 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-05-26 10:45 UTC (permalink / raw)
  To: William J. Schmidt; +Cc: gcc-patches

On Wed, May 25, 2011 at 9:45 PM, William J. Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> Since I'm in process of moving the lowering of pow and powi calls from
> expand into gimple, I wrote some tests to improve coverage in this area.
> Most of these look for specific code generation patterns in PowerPC
> assembly where the existence of a hardware floating square root can be
> guaranteed.
>
> This patch is conditional on patch 3 of the PR46728 series; without it,
> test pr46728-16.c will fail, since the FMA will not be generated.  All
> other tests currently pass.
>
> OK to add to test suite on trunk?

Ok.

Richard.

> Thanks,
> Bill
>
>
> 2011-05-25  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>        * 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.
>
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-13.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-13.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-13.c       (revision 0)
> @@ -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;
> +}
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-3.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-3.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-3.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-14.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-14.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-14.c       (revision 0)
> @@ -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;
> +}
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-4.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-4.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-4.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-15.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-15.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-15.c       (revision 0)
> @@ -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;
> +}
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-5.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-5.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-5.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-16.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-16.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-16.c       (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-7.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-7.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-7.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-10.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-10.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-10.c       (revision 0)
> @@ -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;
> +}
> +
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-8.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-8.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-8.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-11.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-11.c       (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-11.c       (revision 0)
> @@ -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;
> +}
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-1.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-1.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-1.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.target/powerpc/pr46728-2.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr46728-2.c        (revision 0)
> +++ gcc/testsuite/gcc.target/powerpc/pr46728-2.c        (revision 0)
> @@ -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*-*-* } } } */
> Index: gcc/testsuite/gcc.dg/pr46728-9.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr46728-9.c    (revision 0)
> +++ gcc/testsuite/gcc.dg/pr46728-9.c    (revision 0)
> @@ -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;
> +}
> +
> Index: gcc/testsuite/gcc.dg/pr46728-12.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr46728-12.c   (revision 0)
> +++ gcc/testsuite/gcc.dg/pr46728-12.c   (revision 0)
> @@ -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;
> +}
> Index: gcc/testsuite/gcc.dg/pr46728-6.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr46728-6.c    (revision 0)
> +++ gcc/testsuite/gcc.dg/pr46728-6.c    (revision 0)
> @@ -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" } } */
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-26  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 21:05 [PATCH, testsuite] Additional tests for PR46728 (PR46728 patch 4) William J. Schmidt
2011-05-26 10:45 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).