aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2003-08-02 19:14:25 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2003-08-02 19:14:25 +0000
commit8e9dd1eb3ded7ed491b4c392635ec713c342f5d5 (patch)
tree7d3064a06ef5fd6d5fc401ba5d07e750ecd2e0eb
parentfd9aef9d180a377a8804a40a89284956f36f0016 (diff)
downloadgcc-8e9dd1eb3ded7ed491b4c392635ec713c342f5d5.zip
gcc-8e9dd1eb3ded7ed491b4c392635ec713c342f5d5.tar.gz
gcc-8e9dd1eb3ded7ed491b4c392635ec713c342f5d5.tar.bz2
builtins-1.c: Add macro helpers.
* gcc.dg/builtins-1.c: Add macro helpers. Add missing math builtins. Move cases from builtins-4.c here. * gcc.dg/torture/builtin-math-1.c: New test taken from bits of gcc.dg/builtins-3.c, gcc.dg/builtins-5.c and also some additional cases. * gcc.dg/builtins-3.c, gcc.dg/builtins-4.c, gcc.dg/builtins-5.c: Delete. From-SVN: r70108
-rw-r--r--gcc/testsuite/ChangeLog12
-rw-r--r--gcc/testsuite/gcc.dg/builtins-1.c72
-rw-r--r--gcc/testsuite/gcc.dg/builtins-3.c90
-rw-r--r--gcc/testsuite/gcc.dg/builtins-4.c25
-rw-r--r--gcc/testsuite/gcc.dg/builtins-5.c45
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-1.c131
6 files changed, 191 insertions, 184 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 93da359..95a108d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+2003-08-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.dg/builtins-1.c: Add macro helpers. Add missing math
+ builtins. Move cases from builtins-4.c here.
+
+ * gcc.dg/torture/builtin-math-1.c: New test taken from
+ bits of gcc.dg/builtins-3.c, gcc.dg/builtins-5.c and also some
+ additional cases.
+
+ * gcc.dg/builtins-3.c, gcc.dg/builtins-4.c, gcc.dg/builtins-5.c:
+ Delete.
+
2003-08-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9447
diff --git a/gcc/testsuite/gcc.dg/builtins-1.c b/gcc/testsuite/gcc.dg/builtins-1.c
index 33160ab..ae00082 100644
--- a/gcc/testsuite/gcc.dg/builtins-1.c
+++ b/gcc/testsuite/gcc.dg/builtins-1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation.
+/* Copyright (C) 2002, 2003 Free Software Foundation.
Verify that all the __builtin_ math functions are recognized
by the compiler.
@@ -8,27 +8,51 @@
/* { dg-do compile } */
/* { dg-final { scan-assembler-not "__builtin_" } } */
-double test1(double x) { return __builtin_sqrt(x); }
-double test2(double x) { return __builtin_cos(x); }
-double test3(double x) { return __builtin_sin(x); }
-double test4(double x) { return __builtin_exp(x); }
-double test5(double x) { return __builtin_log(x); }
-double test6(double x) { return __builtin_tan(x); }
-double test7(double x) { return __builtin_atan(x); }
-
-float test1f(float x) { return __builtin_sqrtf(x); }
-float test2f(float x) { return __builtin_cosf(x); }
-float test3f(float x) { return __builtin_sinf(x); }
-float test4f(float x) { return __builtin_expf(x); }
-float test5f(float x) { return __builtin_logf(x); }
-float test6f(float x) { return __builtin_tanf(x); }
-float test7f(float x) { return __builtin_atanf(x); }
-
-long double test1l(long double x) { return __builtin_sqrtl(x); }
-long double test2l(long double x) { return __builtin_cosl(x); }
-long double test3l(long double x) { return __builtin_sinl(x); }
-long double test4l(long double x) { return __builtin_expl(x); }
-long double test5l(long double x) { return __builtin_logl(x); }
-long double test6l(long double x) { return __builtin_tanl(x); }
-long double test7l(long double x) { return __builtin_atanl(x); }
+/* These helper macros ensure we also check the float and long double
+ cases. */
+/* Test FP functions taking void. */
+#define FPTEST0(FN) \
+double test_##FN(void) { return __builtin_##FN(); } \
+float test_##FN##f(void) { return __builtin_##FN##f(); } \
+long double test_##FN##l(void) { return __builtin_##FN##l(); }
+
+/* Test FP functions taking one FP argument. */
+#define FPTEST1(FN) \
+double test_##FN(double x) { return __builtin_##FN(x); } \
+float test_##FN##f(float x) { return __builtin_##FN##f(x); } \
+long double test_##FN##l(long double x) { return __builtin_##FN##l(x); }
+
+/* Test FP functions taking one argument of a supplied type. */
+#define FPTEST1TYPE(FN, TYPE) \
+double test_##FN(TYPE x) { return __builtin_##FN(x); } \
+float test_##FN##f(TYPE x) { return __builtin_##FN##f(x); } \
+long double test_##FN##l(TYPE x) { return __builtin_##FN##l(x); }
+
+/* Test FP functions taking two FP arguments. */
+#define FPTEST2(FN) \
+double test_##FN(double x, double y) { return __builtin_##FN(x, y); } \
+float test_##FN##f(float x, float y) { return __builtin_##FN##f(x, y); } \
+long double test_##FN##l(long double x, long double y) { return __builtin_##FN##l(x, y); }
+
+/* Keep this list sorted alphabetically by function name. */
+FPTEST1 (atan)
+FPTEST2 (atan2)
+FPTEST1 (ceil)
+FPTEST1 (cos)
+FPTEST1 (exp)
+FPTEST1 (fabs)
+FPTEST1 (floor)
+FPTEST2 (fmod)
+FPTEST0 (huge_val)
+FPTEST0 (inf)
+FPTEST1 (log)
+FPTEST1TYPE (nan, char *)
+FPTEST1TYPE (nans, char *)
+FPTEST1 (nearbyint)
+FPTEST2 (pow)
+FPTEST1 (round)
+FPTEST1 (sin)
+FPTEST1 (sqrt)
+FPTEST1 (tan)
+FPTEST1 (trunc)
diff --git a/gcc/testsuite/gcc.dg/builtins-3.c b/gcc/testsuite/gcc.dg/builtins-3.c
deleted file mode 100644
index 4bab231..0000000
--- a/gcc/testsuite/gcc.dg/builtins-3.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation.
-
- Verify that built-in math function constant folding of constant
- arguments is correctly performed by the compiler.
-
- Written by Roger Sayle, 16th August 2002. */
-
-/* { dg-do link } */
-/* { dg-options "-O2 -ffast-math" } */
-
-extern void link_error(void);
-
-int main()
-{
- if (sqrt (0.0) != 0.0)
- link_error ();
-
- if (sqrt (1.0) != 1.0)
- link_error ();
-
- if (exp (0.0) != 1.0)
- link_error ();
-
- if (log (1.0) != 0.0)
- link_error ();
-
- if (sin (0.0) != 0.0)
- link_error ();
-
- if (cos (0.0) != 1.0)
- link_error ();
-
- if (tan (0.0) != 0.0)
- link_error ();
-
- if (atan (0.0) != 0.0)
- link_error ();
-
-
- if (sqrtf (0.0f) != 0.0f)
- link_error ();
-
- if (sqrtf (1.0f) != 1.0f)
- link_error ();
-
- if (expf (0.0f) != 1.0f)
- link_error ();
-
- if (logf (1.0f) != 0.0f)
- link_error ();
-
- if (sinf (0.0f) != 0.0f)
- link_error ();
-
- if (cosf (0.0f) != 1.0f)
- link_error ();
-
- if (tanf (0.0f) != 0.0f)
- link_error ();
-
- if (atanf (0.0f) != 0.0f)
- link_error ();
-
- if (sqrtl (0.0l) != 0.0l)
- link_error ();
-
- if (sqrtl (1.0l) != 1.0l)
- link_error ();
-
- if (expl (0.0l) != 1.0l)
- link_error ();
-
- if (logl (1.0l) != 0.0l)
- link_error ();
-
- if (sinl (0.0l) != 0.0l)
- link_error ();
-
- if (cosl (0.0l) != 1.0l)
- link_error ();
-
- if (tanl (0.0l) != 0.0l)
- link_error ();
-
- if (atanl (0.0) != 0.0l)
- link_error ();
-
- return 0;
-}
-
diff --git a/gcc/testsuite/gcc.dg/builtins-4.c b/gcc/testsuite/gcc.dg/builtins-4.c
deleted file mode 100644
index 55e2c91..0000000
--- a/gcc/testsuite/gcc.dg/builtins-4.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation.
-
- Verify that all the binary __builtin_ math functions are
- recognized by the compiler.
-
- Written by Roger Sayle, 6th February 2002. */
-
-/* { dg-do compile } */
-/* { dg-final { scan-assembler-not "__builtin_" } } */
-
-double test1(double x, double y) { return __builtin_pow(x,y); }
-double test2(double x, double y) { return __builtin_atan2(x,y); }
-double test3(double x, double y) { return __builtin_fmod(x,y); }
-
-float test1f(float x, float y) { return __builtin_powf(x,y); }
-float test2f(float x, float y) { return __builtin_atan2f(x,y); }
-float test3f(float x, float y) { return __builtin_fmodf(x,y); }
-
-long double test1l(long double x, long double y)
-{ return __builtin_powl(x,y); }
-long double test2l(long double x, long double y)
-{ return __builtin_atan2l(x,y); }
-long double test3l(long double x, long double y)
-{ return __builtin_fmodl(x,y); }
-
diff --git a/gcc/testsuite/gcc.dg/builtins-5.c b/gcc/testsuite/gcc.dg/builtins-5.c
deleted file mode 100644
index a056812..0000000
--- a/gcc/testsuite/gcc.dg/builtins-5.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation.
-
- Verify that built-in math function constant folding of constant
- arguments is correctly performed by the by the compiler.
-
- Written by Roger Sayle, 20th February 2003. */
-
-/* { dg-do link } */
-/* { dg-options "-O2" } */
-
-extern void link_error(void);
-
-void test(double x)
-{
- if (pow (x, 0.0) != 1.0)
- link_error ();
- if (pow (1.0, x) != 1.0)
- link_error ();
-}
-
-void testf(float x)
-{
- if (powf (x, 0.0f) != 1.0f)
- link_error ();
- if (powf (1.0f, x) != 1.0f)
- link_error ();
-}
-
-void testl(long double x)
-{
- if (powl (x, 0.0l) != 1.0l)
- link_error ();
- if (powl (1.0l, x) != 1.0l)
- link_error ();
-}
-
-int main()
-{
- test (0.0);
- testf (0.0f);
- testl (0.0l);
-
- return 0;
-}
-
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-1.c b/gcc/testsuite/gcc.dg/torture/builtin-math-1.c
new file mode 100644
index 0000000..47b91d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-1.c
@@ -0,0 +1,131 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation.
+
+ Verify that built-in math function constant folding of constant
+ arguments is correctly performed by the compiler.
+
+ Written by Roger Sayle, 16th August 2002. */
+
+/* { dg-do link } */
+
+/* All references to link_error should go away at compile-time. */
+extern void link_error(void);
+
+void test (float f, double d, long double ld)
+{
+ if (sqrt (0.0) != 0.0)
+ link_error ();
+
+ if (sqrt (1.0) != 1.0)
+ link_error ();
+
+ if (exp (0.0) != 1.0)
+ link_error ();
+
+ if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
+ link_error ();
+
+ if (log (1.0) != 0.0)
+ link_error ();
+
+ if (sin (0.0) != 0.0)
+ link_error ();
+
+ if (cos (0.0) != 1.0)
+ link_error ();
+
+ if (tan (0.0) != 0.0)
+ link_error ();
+
+ if (atan (0.0) != 0.0)
+ link_error ();
+
+ if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
+ link_error ();
+
+ if (pow (d, 0.0) != 1.0)
+ link_error ();
+
+ if (pow (1.0, d) != 1.0)
+ link_error ();
+
+
+ if (sqrtf (0.0F) != 0.0F)
+ link_error ();
+
+ if (sqrtf (1.0F) != 1.0F)
+ link_error ();
+
+ if (expf (0.0F) != 1.0F)
+ link_error ();
+
+ if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
+ link_error ();
+
+ if (logf (1.0F) != 0.0F)
+ link_error ();
+
+ if (sinf (0.0F) != 0.0F)
+ link_error ();
+
+ if (cosf (0.0F) != 1.0F)
+ link_error ();
+
+ if (tanf (0.0F) != 0.0F)
+ link_error ();
+
+ if (atanf (0.0F) != 0.0F)
+ link_error ();
+
+ if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
+ link_error ();
+
+ if (powf (f, 0.0F) != 1.0F)
+ link_error ();
+
+ if (powf (1.0F, f) != 1.0F)
+ link_error ();
+
+
+ if (sqrtl (0.0L) != 0.0L)
+ link_error ();
+
+ if (sqrtl (1.0L) != 1.0L)
+ link_error ();
+
+ if (expl (0.0L) != 1.0L)
+ link_error ();
+
+ if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
+ link_error ();
+
+ if (logl (1.0L) != 0.0L)
+ link_error ();
+
+ if (sinl (0.0L) != 0.0L)
+ link_error ();
+
+ if (cosl (0.0L) != 1.0L)
+ link_error ();
+
+ if (tanl (0.0L) != 0.0L)
+ link_error ();
+
+ if (atanl (0.0) != 0.0L)
+ link_error ();
+
+ if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
+ link_error ();
+
+ if (powl (ld, 0.0L) != 1.0L)
+ link_error ();
+
+ if (powl (1.0L, ld) != 1.0L)
+ link_error ();
+}
+
+int main()
+{
+ test (3.0, 3.0F, 3.0L);
+
+ return 0;
+}