diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-10-25 09:46:50 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-11-03 12:54:50 -0400 |
commit | 7ab79a40b546a1470abaf76bec74c63e9990fe47 (patch) | |
tree | 6e109809952740cce8211058a0b44f70aea973c5 /gcc/value-range.h | |
parent | a291237b628f419d7f7ac264dd7b42947b565222 (diff) | |
download | gcc-7ab79a40b546a1470abaf76bec74c63e9990fe47.zip gcc-7ab79a40b546a1470abaf76bec74c63e9990fe47.tar.gz gcc-7ab79a40b546a1470abaf76bec74c63e9990fe47.tar.bz2 |
Adjust operators equal and not_equal to check bitmasks against constants
Check to see if a comparison to a constant can be determined to always
be not-equal based on the bitmask.
PR tree-optimization/111766
gcc/
* range-op.cc (operator_equal::fold_range): Check constants
against the bitmask.
(operator_not_equal::fold_range): Ditto.
* value-range.h (irange_bitmask::member_p): New.
gcc/testsuite/
* gcc.dg/pr111766.c: New.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r-- | gcc/value-range.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h index 84f65ff..330e6f7 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -139,6 +139,7 @@ public: void verify_mask () const; void dump (FILE *) const; + bool member_p (const wide_int &val) const; void adjust_range (irange &r) const; // Convenience functions for nonzero bitmask compatibility. @@ -202,6 +203,19 @@ irange_bitmask::set_nonzero_bits (const wide_int &bits) verify_mask (); } +// Return TRUE if val could be a valid value with this bitmask. + +inline bool +irange_bitmask::member_p (const wide_int &val) const +{ + if (unknown_p ()) + return true; + wide_int res = m_mask & val; + if (m_value != 0) + res |= ~m_mask & m_value; + return res == val; +} + inline bool irange_bitmask::operator== (const irange_bitmask &src) const { |