aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2008-10-28 12:10:18 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2008-10-28 12:10:18 +0000
commit938d35bd4a257e6bdb74358367d21010d3fd95e2 (patch)
tree3efd18f0ac8dd5189ad0d10eb497d249ab2083a4
parent5229689d71b35d2e94c1c2f80147927bf5470c07 (diff)
downloadgcc-938d35bd4a257e6bdb74358367d21010d3fd95e2.zip
gcc-938d35bd4a257e6bdb74358367d21010d3fd95e2.tar.gz
gcc-938d35bd4a257e6bdb74358367d21010d3fd95e2.tar.bz2
convert.c (strip_float_extensions): Do not remove or introduce conversions between binary and decimal...
* convert.c (strip_float_extensions): Do not remove or introduce conversions between binary and decimal floating-point types. testsuite: * gcc.dg/dfp/convert-bfp-12.c: New test. From-SVN: r141407
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/convert.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c17
4 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d04aa06..5b520af 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-28 Joseph Myers <joseph@codesourcery.com>
+
+ * convert.c (strip_float_extensions): Do not remove or introduce
+ conversions between binary and decimal floating-point types.
+
2008-10-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37931
diff --git a/gcc/convert.c b/gcc/convert.c
index 0fef3a2..2461772 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -81,7 +81,7 @@ strip_float_extensions (tree exp)
it properly and handle it like (type)(narrowest_type)constant.
This way we can optimize for instance a=a*2.0 where "a" is float
but 2.0 is double constant. */
- if (TREE_CODE (exp) == REAL_CST)
+ if (TREE_CODE (exp) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (exp)))
{
REAL_VALUE_TYPE orig;
tree type = NULL;
@@ -108,6 +108,9 @@ strip_float_extensions (tree exp)
if (!FLOAT_TYPE_P (subt))
return exp;
+ if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt))
+ return exp;
+
if (TYPE_PRECISION (subt) > TYPE_PRECISION (expt))
return exp;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 58e7819..0281e86 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-28 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/dfp/convert-bfp-12.c: New test.
+
2008-10-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37931
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c
new file mode 100644
index 0000000..9638141
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c
@@ -0,0 +1,17 @@
+/* Test for bug where fold wrongly removed conversions to double and
+ replaced them by conversions to float. */
+/* { dg-options "-std=gnu99" } */
+
+extern void abort (void);
+extern void exit (int);
+
+volatile float f = __builtin_inff ();
+volatile _Decimal32 d32 = 1e40DF;
+
+int
+main (void)
+{
+ if ((double) f == (double) d32)
+ abort ();
+ exit (0);
+}