[COMMITTED] Do not double print INF and NAN in frange pretty printer.

Message ID 20221006062318.1709996-1-aldyh@redhat.com
State New, archived
Headers
Series [COMMITTED] Do not double print INF and NAN in frange pretty printer. |

Commit Message

Aldy Hernandez Oct. 6, 2022, 6:23 a.m. UTC
  gcc/ChangeLog:

	* value-range-pretty-print.cc (vrange_printer::print_real_value):
	Avoid printing INF and NAN twice.
---
 gcc/value-range-pretty-print.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc
index 8cbe97b76fd..3a3b4b44cbd 100644
--- a/gcc/value-range-pretty-print.cc
+++ b/gcc/value-range-pretty-print.cc
@@ -123,7 +123,11 @@  vrange_printer::print_real_value (tree type, const REAL_VALUE_TYPE &r) const
   char s[100];
   real_to_decimal_for_mode (s, &r, sizeof (s), 0, 1, TYPE_MODE (type));
   pp_string (pp, s);
-  if (!DECIMAL_FLOAT_TYPE_P (type))
+  if (!DECIMAL_FLOAT_TYPE_P (type)
+      // real_to_hexadecimal prints infinities and NAN as text.  No
+      // need to print them twice.
+      && !real_isinf (&r)
+      && !real_isnan (&r))
     {
       real_to_hexadecimal (s, &r, sizeof (s), 0, 1);
       pp_printf (pp, " (%s)", s);