Skip to content

Commit

Permalink
Return true from operator== for two identical ranges containing NAN.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aldyh committed Apr 18, 2023
1 parent 4d747ea commit 10e481b
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions gcc/value-range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ();
Expand Down

0 comments on commit 10e481b

Please sign in to comment.