diff mbox series

[COMMITTED] Add frange::update_nan (const nan_state &).

Message ID 20230919163052.865027-2-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] Add frange::update_nan (const nan_state &). | expand

Commit Message

Aldy Hernandez Sept. 19, 2023, 4:30 p.m. UTC
We can set_nan() with a nan_state so it's good form to have the
analogous form for update_nan().

gcc/ChangeLog:

	* value-range.h (frange::update_nan): New.
---
 gcc/value-range.h | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/gcc/value-range.h b/gcc/value-range.h
index da04be00ab4..a792c593faa 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -1257,36 +1257,40 @@  frange::set_undefined ()
     verify_range ();
 }
 
-// Set the NAN bit and adjust the range.
+// Set the NAN bits to NAN and adjust the range.
 
 inline void
-frange::update_nan ()
+frange::update_nan (const nan_state &nan)
 {
   gcc_checking_assert (!undefined_p ());
   if (HONOR_NANS (m_type))
     {
-      m_pos_nan = true;
-      m_neg_nan = true;
+      m_pos_nan = nan.pos_p ();
+      m_neg_nan = nan.neg_p ();
       normalize_kind ();
       if (flag_checking)
 	verify_range ();
     }
 }
 
+// Set the NAN bit to +-NAN.
+
+inline void
+frange::update_nan ()
+{
+  gcc_checking_assert (!undefined_p ());
+  nan_state nan (true);
+  update_nan (nan);
+}
+
 // Like above, but set the sign of the NAN.
 
 inline void
 frange::update_nan (bool sign)
 {
   gcc_checking_assert (!undefined_p ());
-  if (HONOR_NANS (m_type))
-    {
-      m_pos_nan = !sign;
-      m_neg_nan = sign;
-      normalize_kind ();
-      if (flag_checking)
-	verify_range ();
-    }
+  nan_state nan (/*pos=*/!sign, /*neg=*/sign);
+  update_nan (nan);
 }
 
 inline bool