summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-05 23:30:04 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-05 23:30:04 +0000
commit7e50d9b5379a2ba16a5772976876807f6d5a282f (patch)
tree7565b48cdb356b8efb4e7cca01d3b79f02077194
parent236d4a66c20c4f418596cb4ae7acfafb37a46ffe (diff)
downloadgcc-7e50d9b5379a2ba16a5772976876807f6d5a282f.tar.gz
* convert.c (convert_to_integer): Fix nearbyint/rint -> *lrint
conversion. testsuite: * gcc.dg/torture/builtin-convert-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122581 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/convert.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-convert-4.c37
4 files changed, 49 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a27533fedfe..f6a9af9a854 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * convert.c (convert_to_integer): Fix nearbyint/rint -> *lrint
+ conversion.
+
2007-03-05 Ian Lance Taylor <iant@google.com>
* c.opt (fgnu89-inline): New option.
diff --git a/gcc/convert.c b/gcc/convert.c
index b6c6d0fcf75..82b40bad0a7 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -413,12 +413,12 @@ convert_to_integer (tree type, tree expr)
fn = mathfn_built_in (s_intype, BUILT_IN_LLROUND);
break;
- CASE_FLT_FN (BUILT_IN_RINT):
- /* Only convert rint* if we can ignore math exceptions. */
+ CASE_FLT_FN (BUILT_IN_NEARBYINT):
+ /* Only convert nearbyint* if we can ignore math exceptions. */
if (flag_trapping_math)
break;
/* ... Fall through ... */
- CASE_FLT_FN (BUILT_IN_NEARBYINT):
+ CASE_FLT_FN (BUILT_IN_RINT):
if (outprec < TYPE_PRECISION (long_integer_type_node)
|| (outprec == TYPE_PRECISION (long_integer_type_node)
&& !TYPE_UNSIGNED (type)))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c3205c6140f..7753a04e5ae 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-03-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.dg/torture/builtin-convert-4.c: New test.
+
2007-03-05 Ian Lance Taylor <iant@google.com>
* gcc.c-torture/compile/pr31034.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c
new file mode 100644
index 00000000000..c37bd5e2e8a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-4.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Verify that nearbyint isn't transformed into e.g. rint or lrint
+ when -ftrapping-math is set.
+
+ Written by Kaveh ghazi, 2007-03-04. */
+
+/* { dg-do compile } */
+/* { dg-options "-ftrapping-math -fdump-tree-original" } */
+/* { dg-options "-ftrapping-math -fdump-tree-original -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
+/* { dg-options "-ftrapping-math -fdump-tree-original -std=c99" { target *-*-solaris2* } } */
+
+#include "../builtins-config.h"
+
+extern void bar (long);
+
+#define TESTIT(FUNC) do { \
+ bar (__builtin_##FUNC(d)); \
+ bar (__builtin_##FUNC##f(f)); \
+ bar (__builtin_##FUNC##l(ld)); \
+} while (0)
+
+void __attribute__ ((__noinline__)) foo (double d, float f, long double ld)
+{
+ TESTIT(nearbyint);
+}
+
+int main()
+{
+ foo (1.0, 2.0, 3.0);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "nearbyint " 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "nearbyintf" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "nearbyintl" 1 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */