https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120817

--- Comment #18 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 7 Jul 2025, tnfchris at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120817
> 
> --- Comment #17 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #16)
> > No, that cannot be required for correct operation.  I think DSE is wrong in
> > assessing that the store covers more than 5 bytes.  The following fixes it
> > for me
> > 
> > diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
> > index 5ac4280ee36..51a572316cd 100644
> > --- a/gcc/tree-ssa-dse.cc
> > +++ b/gcc/tree-ssa-dse.cc
> > @@ -181,10 +181,10 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref
> > *write, bool may_def_ok = false)
> >                can provide a may-def variant.  */
> >             if (may_def_ok)
> >               {
> > -               ao_ref_init_from_ptr_and_size (
> > -                 write, gimple_call_arg (stmt, 0),
> > -                 TYPE_SIZE_UNIT (
> > -                   TREE_TYPE (gimple_call_arg (stmt, 
> > stored_value_index))));
> > +               ao_ref_init_from_ptr_and_range (
> > +                 write, gimple_call_arg (stmt, 0), true, 0, -1,
> > +                 tree_to_poly_int64 (TYPE_SIZE (
> > +                   TREE_TYPE (gimple_call_arg (stmt,
> > stored_value_index)))));
> >                 return true;
> >               }
> >             break;
> > 
> 
> That's the same as I was suggesting on IRC, the only difference is that I
> handled it in the called, since the rang *is* known if the value is a poly
> constant.  So I think this change is overzealous as it does block vectp_+
> POLY_INT_CST where we do know the offset.

It shouldn't block that case, it will still pick up the extra offset
and get access to the adjusted base.

Reply via email to