aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2006-11-11 04:01:42 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2006-11-11 04:01:42 +0000
commit345768ef3f0ad0f2b09cbd79ec4daf6ba48f51b7 (patch)
treea01015034e7637e43c95e5386ce6b1d3c4aa4f9d
parentb8b7f1621f4c8270babb2a492e3f58413a368741 (diff)
downloadgcc-345768ef3f0ad0f2b09cbd79ec4daf6ba48f51b7.zip
gcc-345768ef3f0ad0f2b09cbd79ec4daf6ba48f51b7.tar.gz
gcc-345768ef3f0ad0f2b09cbd79ec4daf6ba48f51b7.tar.bz2
fold-const.c (negate_mathfn_p): Add BUILT_IN_ERF.
* fold-const.c (negate_mathfn_p): Add BUILT_IN_ERF. testsuite: * gcc.dg/torture/builtin-symmetric-1.c: New test. From-SVN: r118682
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/fold-const.c1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c54
4 files changed, 63 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7f38662..a4c8553 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2006-11-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * fold-const.c (negate_mathfn_p): Add BUILT_IN_ERF.
+
2006-11-10 Roger Sayle <roger@eyesopen.com>
* tree.c (build_int_cst_wide): Add an assertion (gcc_unreachable)
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 6016a70..fedc3ca 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -894,6 +894,7 @@ negate_mathfn_p (enum built_in_function code)
CASE_FLT_FN (BUILT_IN_SINH):
CASE_FLT_FN (BUILT_IN_TAN):
CASE_FLT_FN (BUILT_IN_TANH):
+ CASE_FLT_FN (BUILT_IN_ERF):
return true;
default:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3880cb9..7566130 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2006-11-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.dg/torture/builtin-symmetric-1.c: New test.
+
2006-11-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29758
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c b/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c
new file mode 100644
index 0000000..49be06f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-symmetric-1.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2006 Free Software Foundation.
+
+ Verify that built-in math function folding of symmetric even and
+ odd functions is correctly performed by the compiler.
+
+ Origin: Kaveh R. Ghazi, November 09, 2006. */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(int);
+
+/* Test that FUNC(-ARG) == FUNC(ARG). */
+#define TESTIT_EVEN(FUNC) do { \
+ if (__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
+ link_error(__LINE__); \
+ if (__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+/* Test that -FUNC(ARG) == FUNC(-ARG). */
+#define TESTIT_ODD(FUNC) do { \
+ if (-__builtin_##FUNC##f(-xf) != __builtin_##FUNC##f(xf)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC(-x) != __builtin_##FUNC(x)) \
+ link_error(__LINE__); \
+ if (-__builtin_##FUNC##l(-xl) != __builtin_##FUNC##l(xl)) \
+ link_error(__LINE__); \
+ } while (0)
+
+void foo (float xf, double x, long double xl)
+{
+ TESTIT_EVEN(cos);
+
+ TESTIT_ODD(asin);
+ TESTIT_ODD(asinh);
+ TESTIT_ODD(atan);
+ TESTIT_ODD(atanh);
+ TESTIT_ODD(cbrt);
+ TESTIT_ODD(sin);
+ TESTIT_ODD(sinh);
+ TESTIT_ODD(tan);
+ TESTIT_ODD(tanh);
+ TESTIT_ODD(erf);
+}
+
+int main()
+{
+ foo (1,1,1);
+ return 0;
+}