aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-01-23 18:37:16 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-01-23 18:37:16 +0000
commit92c7bc2abc9f7e1753f520b83fa857675388cbf8 (patch)
tree7f1e5ebbd185294c70a871585d99b45e02a50edf
parent04b8f97f29948de584315b23a38d8d1cfc85bd17 (diff)
downloadgcc-92c7bc2abc9f7e1753f520b83fa857675388cbf8.zip
gcc-92c7bc2abc9f7e1753f520b83fa857675388cbf8.tar.gz
gcc-92c7bc2abc9f7e1753f520b83fa857675388cbf8.tar.bz2
* gcc.dg/builtins-29.c: New test case.
From-SVN: r76444
-rw-r--r--gcc/ChangeLog2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/builtins-29.c96
3 files changed, 100 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 94a3436..84fa8aa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -36,8 +36,6 @@
round, roundf and roundl.
(fold_builtin): Call fold_builtin_round for BUILT_IN_ROUND{,F,L}.
- * gcc.dg/builtins-29.c: New test case.
-
2004-01-23 Alexandre Oliva <aoliva@redhat.com>
PR optimization/13819
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 848ca88..0e37a58 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-01-23 Roger Sayle <roger@eyesopen.com>
+
+ * gcc.dg/builtins-29.c: New test case.
+
2004-01-23 Zack Weinberg <zack@codesourcery.com>
PR 18314
diff --git a/gcc/testsuite/gcc.dg/builtins-29.c b/gcc/testsuite/gcc.dg/builtins-29.c
new file mode 100644
index 0000000..30f9bad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-29.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Check that constant folding of round, roundf and roundl math functions
+ doesn't break anything and produces the expected results.
+
+ Written by Roger Sayle, 22nd January 2004. */
+
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+extern void link_error(void);
+
+extern double round(double);
+extern float roundf(float);
+extern long double roundl(long double);
+
+void test()
+{
+ if (round (0.0) != 0.0)
+ link_error ();
+ if (round (6.0) != 6.0)
+ link_error ();
+ if (round (-8.0) != -8.0)
+ link_error ();
+
+ if (round (3.2) != 3.0)
+ link_error ();
+ if (round (-2.8) != -3.0)
+ link_error ();
+ if (round (0.01) != 0.0)
+ link_error ();
+ if (round (-0.7) != -1.0)
+ link_error ();
+
+ if (round (2.5) != 3.0)
+ link_error ();
+ if (round (-1.5) != -2.0)
+ link_error ();
+}
+
+void testf()
+{
+ if (roundf (0.0f) != 0.0f)
+ link_error ();
+ if (roundf (6.0f) != 6.0f)
+ link_error ();
+ if (roundf (-8.0f) != -8.0f)
+ link_error ();
+
+ if (roundf (3.2f) != 3.0f)
+ link_error ();
+ if (roundf (-2.8f) != -3.0f)
+ link_error ();
+ if (roundf (0.01f) != 0.0f)
+ link_error ();
+ if (roundf (-0.7f) != -1.0f)
+ link_error ();
+
+ if (roundf (2.5f) != 3.0f)
+ link_error ();
+ if (roundf (-1.5f) != -2.0f)
+ link_error ();
+}
+
+void testl()
+{
+ if (roundl (0.0l) != 0.0l)
+ link_error ();
+ if (roundl (6.0l) != 6.0l)
+ link_error ();
+ if (roundl (-8.0l) != -8.0l)
+ link_error ();
+
+ if (roundl (3.2l) != 3.0l)
+ link_error ();
+ if (roundl (-2.8l) != -3.0l)
+ link_error ();
+ if (roundl (0.01l) != 0.0l)
+ link_error ();
+ if (roundl (-0.7l) != -1.0l)
+ link_error ();
+
+ if (roundl (2.5l) != 3.0l)
+ link_error ();
+ if (roundl (-1.5l) != -2.0l)
+ link_error ();
+}
+
+int main()
+{
+ test ();
+ testf ();
+ testl ();
+ return 0;
+}
+