Skip to content

Commit

Permalink
Handle NANs in frange::operator== [PR109593]
Browse files Browse the repository at this point in the history
This patch...
	commit 10e481b
	Return true from operator== for two identical ranges containing NAN.

removed the check for NANs, which caused us to read from m_min and
m_max which are undefined for NANs.

gcc/ChangeLog:

	PR tree-optimization/109593
	* value-range.cc (frange::operator==): Handle NANs.
  • Loading branch information
aldyh committed Apr 23, 2023
1 parent 525713e commit 5830953
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gcc/value-range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,16 @@ frange::operator== (const frange &src) const
if (varying_p ())
return types_compatible_p (m_type, src.m_type);

bool nan1 = known_isnan ();
bool nan2 = src.known_isnan ();
if (nan1 || nan2)
{
if (nan1 && nan2)
return (m_pos_nan == src.m_pos_nan
&& m_neg_nan == src.m_neg_nan);
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

0 comments on commit 5830953

Please sign in to comment.