]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Minor fixes to frange.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 14 Sep 2022 05:49:55 +0000 (07:49 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 14 Sep 2022 15:06:48 +0000 (17:06 +0200)
Following are a series of cleanups to the frange code in preparation
for a much more invasive patch rewriting the NAN and sign tracking
bits.  Please be patient, as I'm trying to break everything up into
small chunks instead of dropping a mondo patch removing the NAN and
sign tristate handling.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* value-query.cc (range_query::get_tree_range): Remove check for overflow.
* value-range-pretty-print.cc (vrange_printer::visit): Move read
of type until after undefined_p is checked.
* value-range.cc (frange::set): Remove asserts for REAL_CST.
(frange::contains_p): Tidy up.
(range_tests_nan):  Add comment.
* value-range.h (frange::type): Check for undefined_p.
(frange::set_undefined): Remove set of endpoints.

gcc/value-query.cc
gcc/value-range-pretty-print.cc
gcc/value-range.cc
gcc/value-range.h

index ad80db780c22404d0c5451b2eab12f32e30e0efd..de83f469be4e44d4741b5c9e9e9ff5302499b56f 100644 (file)
@@ -217,9 +217,6 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt)
 
     case REAL_CST:
       {
-       if (TREE_OVERFLOW_P (expr))
-         expr = drop_tree_overflow (expr);
-
        frange &f = as_a <frange> (r);
        f.set (expr, expr);
 
index 93e18d3c1b6339828db14b58fd3ec5a6e5b538a8..b124e46cb9e127e68c9f207f3762608f3070c387 100644 (file)
@@ -122,14 +122,13 @@ vrange_printer::print_irange_bitmasks (const irange &r) const
 void
 vrange_printer::visit (const frange &r) const
 {
-  tree type = r.type ();
-
   pp_string (pp, "[frange] ");
   if (r.undefined_p ())
     {
       pp_string (pp, "UNDEFINED");
       return;
     }
+  tree type = r.type ();
   dump_generic_node (pp, type, 0, TDF_NONE, false);
   pp_string (pp, " ");
   if (r.varying_p ())
index 6f0609959b3bc5a808e131f8cd3a34b7be21f5ea..d40a4ebf657f5534269ebc05f40d85d718266d11 100644 (file)
@@ -357,15 +357,11 @@ frange::set_signbit (fp_prop::kind k)
 void
 frange::set (tree min, tree max, value_range_kind kind)
 {
-  gcc_checking_assert (TREE_CODE (min) == REAL_CST);
-  gcc_checking_assert (TREE_CODE (max) == REAL_CST);
-
   if (kind == VR_UNDEFINED)
     {
       set_undefined ();
       return;
     }
-
   // Treat VR_ANTI_RANGE and VR_VARYING as varying.
   if (kind != VR_RANGE)
     {
@@ -401,7 +397,6 @@ frange::set (tree min, tree max, value_range_kind kind)
   gcc_checking_assert (is_nan || tree_compare (LE_EXPR, min, max));
 
   normalize_kind ();
-
   if (flag_checking)
     verify_range ();
 }
@@ -612,17 +607,17 @@ frange::operator== (const frange &src) const
 bool
 frange::contains_p (tree cst) const
 {
+  gcc_checking_assert (m_kind != VR_ANTI_RANGE);
+  const REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (cst);
+
   if (undefined_p ())
     return false;
 
   if (varying_p ())
     return true;
 
-  gcc_checking_assert (m_kind == VR_RANGE);
 
-  const REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (cst);
-  if (real_compare (GE_EXPR, rv, &m_min)
-      && real_compare (LE_EXPR, rv, &m_max))
+  if (real_compare (GE_EXPR, rv, &m_min) && real_compare (LE_EXPR, rv, &m_max))
     {
       if (HONOR_SIGNED_ZEROS (m_type) && real_iszero (rv))
        {
@@ -3652,7 +3647,7 @@ range_tests_nan ()
   ASSERT_FALSE (r0 == r0);
   ASSERT_TRUE (r0 != r0);
 
-  // [5,6] U NAN.
+  // [5,6] U NAN = [5,6] NAN.
   r0 = frange_float ("5", "6");
   r0.set_nan (fp_prop::NO);
   r1 = frange_nan (float_type_node);
index f9a01ee7a0593f2e1d4a045419617e1b6844b9d1..0ba0193bc1f199156bc8782db850b5aaf7bb3e61 100644 (file)
@@ -1141,6 +1141,7 @@ frange::frange (tree min, tree max, value_range_kind kind)
 inline tree
 frange::type () const
 {
+  gcc_checking_assert (!undefined_p ());
   return m_type;
 }
 
@@ -1160,8 +1161,6 @@ frange::set_undefined ()
   m_kind = VR_UNDEFINED;
   m_type = NULL;
   m_props.set_undefined ();
-  memset (&m_min, 0, sizeof (m_min));
-  memset (&m_max, 0, sizeof (m_max));
 }
 
 // Set R to maximum representable value for TYPE.