On Tue, Nov 3, 2026 at 5:04 PM Andrew MacLeod <[email protected]> wrote:
>
> Have a few independent cleanups enabled by prange being in the global tables
> now. hopefully the formatting is better!
>
> CCP has special casing for pointers to set the alignment based on any
> constant bits. This is no longer needed as pointers now have bitamsks as
> well. This can be generalized in the set-bitmask routine and simplifies the
> CCP code.
>
> Bootstraps on x86_64-pc-linux-gnu with no regressions. OK for trunk?
OK
> Andrew
>
>
>
>
> 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.
> ---
> 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 05162cc89f5..f81a52afba8 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 c760d9370ad..e5f12bc9b39 100644
> --- a/gcc/tree-ssanames.cc
> +++ b/gcc/tree-ssanames.cc
> @@ -546,7 +546,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));
> --
> 2.56.0
>