]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/95118 - fix printing of denormal zero
authorRichard Biener <rguenther@suse.de>
Thu, 14 May 2020 06:53:03 +0000 (08:53 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 23 Jun 2020 11:05:38 +0000 (13:05 +0200)
This fixes printing a REAL_CST generated from value-numbering
punning some bits to a real which turns out as zero with big
negative exponent.  This causes the loop in real_to_decimal_for_mode to
never terminate.

2020-05-14  Richard Biener  <rguenther@suse.de>

PR middle-end/95118
* real.c (real_to_decimal_for_mode): Make sure we handle
a zero with nonzero exponent.

* gcc.dg/pr95118.c: New testcase.

gcc/real.c
gcc/testsuite/gcc.dg/pr95118.c [new file with mode: 0644]

index 00b23ceb41e44a8685f24495299e425d2c018e48..09ec5c08c3863e18f498009e9a3d36522f6c2a9d 100644 (file)
@@ -1714,8 +1714,8 @@ real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig,
 
          do_multiply (&u, &v, ten);
 
-         /* Stop if we're now >= 1.  */
-         if (REAL_EXP (&u) > 0)
+         /* Stop if we're now >= 1 or zero.  */
+         if (REAL_EXP (&u) > 0 || u.cl == rvc_zero)
            break;
 
          v = u;
diff --git a/gcc/testsuite/gcc.dg/pr95118.c b/gcc/testsuite/gcc.dg/pr95118.c
new file mode 100644 (file)
index 0000000..69bc47f
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre" } */
+
+void a();
+void b() {
+    union {
+       int c[4];
+       long double d;
+    } e = {{0, 0, 4}};
+    a(e.d);
+}