]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Return true from operator== for two identical ranges containing NAN.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 26 Jan 2023 03:46:54 +0000 (04:46 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 18 Apr 2023 13:22:23 +0000 (15:22 +0200)
The == operator for ranges signifies that two ranges contain the same
thing, not that they are ultimately equal.  So [2,4] == [2,4], even
though one may be a 2 and the other may be a 3.  Similarly with two
VARYING ranges.

There is an oversight in frange::operator== where we are returning
false for two identical NANs.  This is causing us to never cache NANs
in sbr_sparse_bitmap::set_bb_range.

gcc/ChangeLog:

* value-range.cc (frange::operator==): Adjust for NAN.
(range_tests_nan): Remove some NAN tests.

gcc/value-range.cc

index c14a27e23af90449a7459e3c18de4ee031a9b7e5..8b5d0cb53e46896ff8c01c3af39f3d19df8b4412 100644 (file)
@@ -681,9 +681,6 @@ frange::operator== (const frange &src) const
       if (varying_p ())
        return types_compatible_p (m_type, src.m_type);
 
-      if (known_isnan () || src.known_isnan ())
-       return false;
-
       return (real_identical (&m_min, &src.m_min)
              && real_identical (&m_max, &src.m_max)
              && m_pos_nan == src.m_pos_nan
@@ -3801,13 +3798,6 @@ range_tests_nan ()
       ASSERT_TRUE (r0.maybe_isnan ());
     }
 
-  // NAN ranges are not equal to each other.
-  r0.set_nan (float_type_node);
-  r1 = r0;
-  ASSERT_FALSE (r0 == r1);
-  ASSERT_FALSE (r0 == r0);
-  ASSERT_TRUE (r0 != r0);
-
   // [5,6] U NAN = [5,6] NAN.
   r0 = frange_float ("5", "6");
   r0.clear_nan ();