Skip to content

Commit c496d15

Browse files
committed
A singleton irange has all known bits.
gcc/ChangeLog: * value-range.cc (irange::get_bitmask_from_range): Return all the known bits for a singleton. (irange::set_range_from_bitmask): Set a range of a singleton when all bits are known.
1 parent bf3469b commit c496d15

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

gcc/value-range.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,10 +1766,19 @@ irange::invert ()
17661766
irange_bitmask
17671767
irange::get_bitmask_from_range () const
17681768
{
1769+
unsigned prec = TYPE_PRECISION (type ());
17691770
wide_int min = lower_bound ();
17701771
wide_int max = upper_bound ();
1772+
1773+
// All the bits of a singleton are known.
1774+
if (min == max)
1775+
{
1776+
wide_int mask = wi::zero (prec);
1777+
wide_int value = lower_bound ();
1778+
return irange_bitmask (value, mask);
1779+
}
1780+
17711781
wide_int xorv = min ^ max;
1772-
unsigned prec = TYPE_PRECISION (type ());
17731782

17741783
if (xorv != 0)
17751784
xorv = wi::mask (prec - wi::clz (xorv), false, prec);
@@ -1786,6 +1795,14 @@ irange::set_range_from_bitmask ()
17861795
gcc_checking_assert (!undefined_p ());
17871796
if (m_bitmask.unknown_p ())
17881797
return false;
1798+
1799+
// If all the bits are known, this is a singleton.
1800+
if (m_bitmask.mask () == 0)
1801+
{
1802+
set (m_type, m_bitmask.value (), m_bitmask.value ());
1803+
return true;
1804+
}
1805+
17891806
unsigned popcount = wi::popcount (m_bitmask.get_nonzero_bits ());
17901807

17911808
// If we have only one bit set in the mask, we can figure out the

0 commit comments

Comments
 (0)