diff mbox series

[COMMITTED] Convert ranger uses of real_inf to dconst[n]inf.

Message ID 20220901180547.2866973-1-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] Convert ranger uses of real_inf to dconst[n]inf. | expand

Commit Message

Aldy Hernandez Sept. 1, 2022, 6:05 p.m. UTC
gcc/ChangeLog:

	* range-op-float.cc (build_le): Convert to dconst*inf.
	(build_ge): Same.
	* value-range.cc (frange::set_signbit): Same.
	(frange::normalize_kind): Same.
	(range_tests_floats): Same.
	* value-range.h (vrp_val_max): Same.
	(vrp_val_min): Same.
	(frange::set_varying): Same.
---
 gcc/range-op-float.cc | 16 ++++++----------
 gcc/value-range.cc    | 23 ++++++++---------------
 gcc/value-range.h     | 16 ++++------------
 3 files changed, 18 insertions(+), 37 deletions(-)
diff mbox series

Patch

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 2f1af4055c3..7301e5a060b 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -232,17 +232,15 @@  frange_drop_ninf (frange &r, tree type)
   r.intersect (tmp);
 }
 
-// (X <= VAL) produces the range of [MIN, VAL].
+// (X <= VAL) produces the range of [-INF, VAL].
 
 static void
 build_le (frange &r, tree type, const REAL_VALUE_TYPE &val)
 {
-  REAL_VALUE_TYPE min;
-  real_inf (&min, 1);
-  r.set (type, min, val);
+  r.set (type, dconstninf, val);
 }
 
-// (X < VAL) produces the range of [MIN, VAL).
+// (X < VAL) produces the range of [-INF, VAL).
 
 static void
 build_lt (frange &r, tree type, const REAL_VALUE_TYPE &val)
@@ -251,17 +249,15 @@  build_lt (frange &r, tree type, const REAL_VALUE_TYPE &val)
   build_le (r, type, val);
 }
 
-// (X >= VAL) produces the range of [VAL, MAX].
+// (X >= VAL) produces the range of [VAL, +INF].
 
 static void
 build_ge (frange &r, tree type, const REAL_VALUE_TYPE &val)
 {
-  REAL_VALUE_TYPE max;
-  real_inf (&max, 0);
-  r.set (type, val, max);
+  r.set (type, val, dconstinf);
 }
 
-// (X > VAL) produces the range of (VAL, MAX].
+// (X > VAL) produces the range of (VAL, +INF].
 
 static void
 build_gt (frange &r, tree type, const REAL_VALUE_TYPE &val)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 71581b2c54d..6fd6e3b745c 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -320,18 +320,14 @@  frange::set_signbit (fp_prop::kind k)
   if (k == fp_prop::YES)
     {
       // Crop the range to [-INF, 0].
-      REAL_VALUE_TYPE min;
-      real_inf (&min, 1);
-      frange crop (m_type, min, dconst0);
+      frange crop (m_type, dconstninf, dconst0);
       intersect (crop);
       m_props.set_signbit (fp_prop::YES);
     }
   else if (k == fp_prop::NO)
     {
       // Crop the range to [0, +INF].
-      REAL_VALUE_TYPE max;
-      real_inf (&max, 0);
-      frange crop (m_type, dconst0, max);
+      frange crop (m_type, dconst0, dconstinf);
       intersect (crop);
       m_props.set_signbit (fp_prop::NO);
     }
@@ -440,8 +436,8 @@  frange::normalize_kind ()
       if (!m_props.varying_p ())
 	{
 	  m_kind = VR_RANGE;
-	  real_inf (&m_min, 1);
-	  real_inf (&m_max, 0);
+	  m_min = dconstninf;
+	  m_max = dconstinf;
 	  return true;
 	}
     }
@@ -3785,12 +3781,9 @@  range_tests_floats ()
   ASSERT_FALSE (r0.varying_p ());
 
   // The endpoints of a VARYING are +-INF.
-  REAL_VALUE_TYPE inf, ninf;
-  real_inf (&inf, 0);
-  real_inf (&ninf, 1);
   r0.set_varying (float_type_node);
-  ASSERT_TRUE (real_identical (&r0.lower_bound (), &ninf));
-  ASSERT_TRUE (real_identical (&r0.upper_bound (), &inf));
+  ASSERT_TRUE (real_identical (&r0.lower_bound (), &dconstninf));
+  ASSERT_TRUE (real_identical (&r0.upper_bound (), &dconstinf));
 
   // The maximum representable range for a type is still a subset of VARYING.
   REAL_VALUE_TYPE q, r;
@@ -3800,9 +3793,9 @@  range_tests_floats ()
   // r0 is not a varying, because it does not include -INF/+INF.
   ASSERT_FALSE (r0.varying_p ());
   // The upper bound of r0 must be less than +INF.
-  ASSERT_TRUE (real_less (&r0.upper_bound (), &inf));
+  ASSERT_TRUE (real_less (&r0.upper_bound (), &dconstinf));
   // The lower bound of r0 must be greater than -INF.
-  ASSERT_TRUE (real_less (&ninf, &r0.lower_bound ()));
+  ASSERT_TRUE (real_less (&dconstninf, &r0.lower_bound ()));
 
   // For most architectures, where float and double are different
   // sizes, having the same endpoints does not necessarily mean the
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 3767bd17314..bc00f3d5b08 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -1050,11 +1050,7 @@  vrp_val_max (const_tree type)
       return wide_int_to_tree (const_cast<tree> (type), max);
     }
   if (frange::supports_p (type))
-    {
-      REAL_VALUE_TYPE real;
-      real_inf (&real);
-      return build_real (const_cast <tree> (type), real);
-    }
+    return build_real (const_cast <tree> (type), dconstinf);
   return NULL_TREE;
 }
 
@@ -1068,11 +1064,7 @@  vrp_val_min (const_tree type)
   if (POINTER_TYPE_P (type))
     return build_zero_cst (const_cast<tree> (type));
   if (frange::supports_p (type))
-    {
-      REAL_VALUE_TYPE ninf;
-      real_inf (&ninf, 1);
-      return build_real (const_cast <tree> (type), ninf);
-    }
+    return build_real (const_cast <tree> (type), dconstninf);
   return NULL_TREE;
 }
 
@@ -1145,8 +1137,8 @@  frange::set_varying (tree type)
 {
   m_kind = VR_VARYING;
   m_type = type;
-  real_inf (&m_min, 1);
-  real_inf (&m_max, 0);
+  m_min = dconstninf;
+  m_max = dconstinf;
   m_props.set_varying ();
 }