]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
convert.c (strip_float_extensions): Do not remove or introduce conversions between...
authorJoseph Myers <joseph@codesourcery.com>
Tue, 28 Oct 2008 12:10:18 +0000 (12:10 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Tue, 28 Oct 2008 12:10:18 +0000 (12:10 +0000)
* 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

gcc/ChangeLog
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c [new file with mode: 0644]

index d04aa06a81ccab1ebae3c1baab017fc3d25257b6..5b520af2b09e57000be20b03f204c0994db35f87 100644 (file)
@@ -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
index 0fef3a2e7465a42fe0b327ca20af351984c0230a..24617728298c19432cce6e5081172eb1dd6ccf75 100644 (file)
@@ -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;
 
index 58e7819496af7e26e1feee1036a6bdf150fe16f3..0281e865fe2f389f7ce68bad7fa59e0811563d94 100644 (file)
@@ -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 (file)
index 0000000..9638141
--- /dev/null
@@ -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);
+}