https://gcc.gnu.org/g:0b06547345c6cb4098f376df8af65e5d6b9bbb06
commit r17-5952-g0b06547345c6cb4098f376df8af65e5d6b9bbb06 Author: Andrew MacLeod <[email protected]> Date: Fri Oct 30 16:11:16 2026 -0400 Handle pointers in set_bitmask. CCP has special cases for pointers which restrict the actual information to alignment. This can be handled in set_bitmask. * tree-ssa-ccp.cc (ccp_finalize): Pointers are handled by set_bitmask. * tree-ssanames.cc (set_bitmask): Handle pointers. Diff: --- gcc/tree-ssa-ccp.cc | 29 ++++++----------------------- gcc/tree-ssanames.cc | 8 +++++++- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 05162cc89f54..f81a52afba83 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -1008,13 +1008,10 @@ ccp_finalize (bool nonzero_p) do_dbg_cnt (); - /* Derive alignment and misalignment information from partially - constant pointers in the lattice or nonzero bits from partially - constant integers. */ + /* Derive nonzero and alignment bits from partially constant integers. */ FOR_EACH_SSA_NAME (i, name, cfun) { ccp_prop_value_t *val; - unsigned int tem, align; if (!POINTER_TYPE_P (TREE_TYPE (name)) && (!INTEGRAL_TYPE_P (TREE_TYPE (name)) @@ -1029,25 +1026,11 @@ ccp_finalize (bool nonzero_p) || val->mask == 0) continue; - if (POINTER_TYPE_P (TREE_TYPE (name))) - { - /* Trailing mask bits specify the alignment, trailing value - bits the misalignment. */ - tem = val->mask.to_uhwi (); - align = least_bit_hwi (tem); - if (align > 1) - set_ptr_info_alignment (name, align, - (TREE_INT_CST_LOW (val->value) - & (align - 1))); - } - else - { - unsigned int precision = TYPE_PRECISION (TREE_TYPE (val->value)); - wide_int value = wi::to_wide (val->value); - wide_int mask = wide_int::from (val->mask, precision, UNSIGNED); - value = value & ~mask; - set_bitmask (name, value, mask); - } + unsigned int precision = TYPE_PRECISION (TREE_TYPE (val->value)); + wide_int value = wi::to_wide (val->value); + wide_int mask = wide_int::from (val->mask, precision, UNSIGNED); + value = value & ~mask; + set_bitmask (name, value, mask); } /* Perform substitutions based on the known constant values. */ diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index f64868b497d1..d48d414e6182 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -553,7 +553,13 @@ set_nonzero_bits (tree name, const wide_int &mask) void set_bitmask (tree name, const wide_int &value, const wide_int &mask) { - gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); + if (POINTER_TYPE_P (TREE_TYPE (name))) + { + prange p (TREE_TYPE (name)); + p.update_bitmask (irange_bitmask (value, mask)); + set_range_info (name, p); + return; + } int_range_max r (TREE_TYPE (name)); r.update_bitmask (irange_bitmask (value, mask));
