This patch provides a way to set the value/mask pair of known bits globally, similarly to how we can use set_nonzero_bits for known 0 bits. This can then be used by CCP and IPA to set value/mask info instead of throwing away the known 1 bits.
In further clean-ups, I will see if it makes sense to remove set_nonzero_bits altogether, since it is subsumed by value/mask. gcc/ChangeLog: * tree-ssanames.cc (set_bitmask): New. * tree-ssanames.h (set_bitmask): New. --- gcc/tree-ssanames.cc | 15 +++++++++++++++ gcc/tree-ssanames.h | 1 + 2 files changed, 16 insertions(+) diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 5fdb6a37e9f..f54394363a0 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -465,6 +465,21 @@ set_nonzero_bits (tree name, const wide_int &mask) set_range_info (name, r); } +/* Update the known bits of NAME. + + Zero bits in MASK cover constant values. Set bits in MASK cover + unknown values. VALUE are the known bits. */ + +void +set_bitmask (tree name, const wide_int &value, const wide_int &mask) +{ + gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); + + int_range<2> r (TREE_TYPE (name)); + r.update_bitmask (irange_bitmask (value, mask)); + set_range_info (name, r); +} + /* Return a widest_int with potentially non-zero bits in SSA_NAME NAME, the constant for INTEGER_CST, or -1 if unknown. */ diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index f3fa609208a..b5e3f228ee8 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -59,6 +59,7 @@ struct GTY(()) ptr_info_def /* Sets the value range to SSA. */ extern bool set_range_info (tree, const vrange &); extern void set_nonzero_bits (tree, const wide_int &); +extern void set_bitmask (tree, const wide_int &value, const wide_int &mask); extern wide_int get_nonzero_bits (const_tree); extern bool ssa_name_has_boolean_range (tree); extern void init_ssanames (struct function *, int); -- 2.40.1