re PR debug/48928 (ICE: in decimal_to_decnumber, at dfp.c:113 with -O -g and decimal...
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 May 2011 06:05:20 +0000 (08:05 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 May 2011 06:05:20 +0000 (08:05 +0200)
PR debug/48928
* dfp.c (decimal_to_decnumber): Handle conversion from
dconst{1,2,m1,half}.

* gcc.dg/dfp/pr48928.c: New test.

From-SVN: r173606

gcc/ChangeLog
gcc/dfp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/pr48928.c [new file with mode: 0644]

index 7a6098047ac08ab82bacc707aa7e95d077397c50..0c0efe46aa6ccaee595b46b9002b3fa6d1a101be 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/48928
+       * dfp.c (decimal_to_decnumber): Handle conversion from
+       dconst{1,2,m1,half}.
+
 2011-05-09  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.c (ix86_autovectorize_vector_sizes): Return 0
index 5a18db9f52fb5b1da93a1fdbb0dd6a1c4995daf9..6e43d149cfc5e477a77c57bdaba8e7e4552a1a92 100644 (file)
--- a/gcc/dfp.c
+++ b/gcc/dfp.c
@@ -1,6 +1,6 @@
 /* Decimal floating point support.
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-   Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -110,7 +110,33 @@ decimal_to_decnumber (const REAL_VALUE_TYPE *r, decNumber *dn)
         decNumberFromString (dn, "nan", &set);
       break;
     case rvc_normal:
-      gcc_assert (r->decimal);
+      if (!r->decimal)
+       {
+         /* dconst{1,2,m1,half} are used in various places in
+            the middle-end and optimizers, allow them here
+            as an exception by converting them to decimal.  */
+         if (memcmp (r, &dconst1, sizeof (*r)) == 0)
+           {
+             decNumberFromString (dn, "1", &set);
+             break;
+           }
+         if (memcmp (r, &dconst2, sizeof (*r)) == 0)
+           {
+             decNumberFromString (dn, "2", &set);
+             break;
+           }
+         if (memcmp (r, &dconstm1, sizeof (*r)) == 0)
+           {
+             decNumberFromString (dn, "-1", &set);
+             break;
+           }
+         if (memcmp (r, &dconsthalf, sizeof (*r)) == 0)
+           {
+             decNumberFromString (dn, "0.5", &set);
+             break;
+           }
+         gcc_unreachable ();
+       }
       decimal128ToNumber ((const decimal128 *) r->sig, dn);
       break;
     default:
index 67799ec2bfb358ad157a8ff33d2c0c2a53486b5f..eb2f0735d1ffec7c6e16c50f33470bb6d8011e86 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/48928
+       * gcc.dg/dfp/pr48928.c: New test.
+
 2011-05-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/48522
diff --git a/gcc/testsuite/gcc.dg/dfp/pr48928.c b/gcc/testsuite/gcc.dg/dfp/pr48928.c
new file mode 100644 (file)
index 0000000..1fd3635
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR debug/48928 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+_Decimal32
+foo (_Decimal32 x)
+{
+  _Decimal32 y = (x + x) / (9.DF * x);
+  return y;
+}