On Fri, May 09, 2025 at 09:17:23AM +0200, Richard Biener wrote:
> RTL DSE forms store groups from unique invariant bases but that is
> confused when presented with constant addresses where it assigns
> one store group per unique address. That causes it to not consider
> 0x101:QI to alias 0x100:SI. Constant accesses can really alias
> to every object, in practice they appear for I/O and for access
> to objects fixed via linker scripts for example. So simply avoid
> registering a store group for them.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> OK?
>
> Thanks,
> Richard.
>
> PR rtl-optimization/120182
> * dse.cc (canon_address): Constant addresses have no
> separate store group.
>
> * gcc.dg/torture/pr120182.c: New testcase.
> ---
> gcc/dse.cc | 5 ++-
> gcc/testsuite/gcc.dg/torture/pr120182.c | 42 +++++++++++++++++++++++++
> 2 files changed, 46 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/torture/pr120182.c
>
> diff --git a/gcc/dse.cc b/gcc/dse.cc
> index ffc86ffabe5..2b99c660a9a 100644
> --- a/gcc/dse.cc
> +++ b/gcc/dse.cc
> @@ -1190,7 +1190,10 @@ canon_address (rtx mem,
> address = strip_offset_and_add (address, offset);
>
> if (ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (mem))
> - && const_or_frame_p (address))
> + && const_or_frame_p (address)
> + /* Literal addresses can alias any base, avoid creating a
> + group for them. */
> + && ! CONST_INT_P (address))
Perhaps better CONST_SCALAR_INT_P instead of CONST_INT_P?
Otherwise LGTM.
Jakub