This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Split out some tests from builtins-20.c
- From: Richard Sandiford <richard dot sandiford at arm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Oct 2015 14:18:58 +0100
- Subject: Split out some tests from builtins-20.c
- Authentication-results: sourceware.org; auth=none
Stripping unnecessary sign ops at the gimple level means that we're
no longer able to optimise:
if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y)))
!= cos(y<10 ? x : tan(x<20 ? x : y)))
link_error ();
because we're currently not able to fold away the equality in:
int
f1 (double x, double y)
{
double z1 = __builtin_cos(y<10 ? x : __builtin_tan(x<20 ? x : y));
double z2 = __builtin_cos(y<10 ? x : __builtin_tan(x<20 ? x : y));
return z1 == z2;
}
The missed fold is being tracked as PR 67975. This patch splits the
test out into a separate file so that we can XFAIL it until the PR
is fixed.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
OK to install?
Thanks,
Richard
gcc/testsuite/
* gcc.dg/builtins-20.c: Move some tests to...
* gcc.dg/builtins-86.c: ...this new file.
diff --git a/gcc/testsuite/gcc.dg/builtins-20.c b/gcc/testsuite/gcc.dg/builtins-20.c
index 2b63428..8288367 100644
--- a/gcc/testsuite/gcc.dg/builtins-20.c
+++ b/gcc/testsuite/gcc.dg/builtins-20.c
@@ -115,10 +115,6 @@ void test2(double x, double y)
if (cos(y<10 ? x : -y) != cos(y<10 ? x : y))
link_error ();
- if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y)))
- != cos(y<10 ? x : tan(x<20 ? x : y)))
- link_error ();
-
if (cos((y*=3, -x)) != cos((y*=3,x)))
link_error ();
@@ -343,10 +339,6 @@ void test2f(float x, float y)
if (cosf(y<10 ? x : -y) != cosf(y<10 ? x : y))
link_error ();
- if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y)))
- != cosf(y<10 ? x : tanf(x<20 ? x : y)))
- link_error ();
-
if (cosf((y*=3, -x)) != cosf((y*=3,x)))
link_error ();
@@ -570,10 +562,6 @@ void test2l(long double x, long double y)
if (cosl(y<10 ? x : -y) != cosl(y<10 ? x : y))
link_error ();
- if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y)))
- != cosl(y<10 ? x : tanl(x<20 ? x : y)))
- link_error ();
-
if (cosl((y*=3, -x)) != cosl((y*=3,x)))
link_error ();
diff --git a/gcc/testsuite/gcc.dg/builtins-86.c b/gcc/testsuite/gcc.dg/builtins-86.c
new file mode 100644
index 0000000..f405124
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-86.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003-2015 Free Software Foundation.
+
+ Split out from builtins-20.c, which has the comment:
+
+ Verify that built-in math function constant folding doesn't break
+ anything and produces the expected results.
+
+ Written by Roger Sayle, 8th June 2003. */
+
+/* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */
+
+#include "builtins-config.h"
+
+extern double cos (double);
+extern double tan (double);
+extern double fabs (double);
+extern float cosf (float);
+extern float tanf (float);
+extern float fabsf (float);
+extern long double cosl (long double);
+extern long double tanl (long double);
+extern long double fabsl (long double);
+
+extern void link_error(void);
+
+void test2(double x, double y)
+{
+ if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y)))
+ != cos(y<10 ? x : tan(x<20 ? x : y)))
+ link_error ();
+}
+
+void test2f(float x, float y)
+{
+ if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y)))
+ != cosf(y<10 ? x : tanf(x<20 ? x : y)))
+ link_error ();
+}
+
+void test2l(long double x, long double y)
+{
+ if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y)))
+ != cosl(y<10 ? x : tanl(x<20 ? x : y)))
+ link_error ();
+}
+
+int main()
+{
+ test2 (1.0, 2.0);
+ test2f (1.0f, 2.0f);
+ test2l (1.0l, 2.0l);
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */