[PATCH] Improve DSE to handle redundant zero initializations.

Matthew Beliveau mbelivea@redhat.com
Tue Aug 13 15:18:00 GMT 2019


Hello,

This should have the changes you all asked for! Let me know if I
missed anything!

Thank you,
Matthew Beliveau

On Tue, Aug 13, 2019 at 5:15 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Tue, Aug 13, 2019 at 10:18 AM Richard Sandiford
> <richard.sandiford@arm.com> wrote:
> >
> > Thanks for doing this.
> >
> > Matthew Beliveau <mbelivea@redhat.com> writes:
> > > diff --git gcc/tree-ssa-dse.c gcc/tree-ssa-dse.c
> > > index 5b7c4fc6d1a..dcaeb8edbfe 100644
> > > --- gcc/tree-ssa-dse.c
> > > +++ gcc/tree-ssa-dse.c
> > > @@ -628,11 +628,8 @@ dse_optimize_redundant_stores (gimple *stmt)
> > >        tree fndecl;
> > >        if ((is_gimple_assign (use_stmt)
> > >          && gimple_vdef (use_stmt)
> > > -        && ((gimple_assign_rhs_code (use_stmt) == CONSTRUCTOR
> > > -             && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (use_stmt)) == 0
> > > -             && !gimple_clobber_p (stmt))
> > > -            || (gimple_assign_rhs_code (use_stmt) == INTEGER_CST
> > > -                && integer_zerop (gimple_assign_rhs1 (use_stmt)))))
> > > +        && initializer_zerop (gimple_op (use_stmt, 1), NULL)
> > > +        && !gimple_clobber_p (stmt))
> > >         || (gimple_call_builtin_p (use_stmt, BUILT_IN_NORMAL)
> > >             && (fndecl = gimple_call_fndecl (use_stmt)) != NULL
> > >             && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMSET
> > > @@ -1027,15 +1024,13 @@ dse_dom_walker::dse_optimize_stmt (gimple_stmt_iterator *gsi)
> > >      {
> > >        bool by_clobber_p = false;
> > >
> > > -      /* First see if this store is a CONSTRUCTOR and if there
> > > -      are subsequent CONSTRUCTOR stores which are totally
> > > -      subsumed by this statement.  If so remove the subsequent
> > > -      CONSTRUCTOR store.
> > > +      /* Check if this store initalizes zero, or some aggregate of zeros,
> > > +      and check if there are subsequent stores which are subsumed by this
> > > +      statement.  If so, remove the subsequent store.
> > >
> > >        This will tend to make fewer calls into memset with longer
> > >        arguments.  */
> > > -      if (gimple_assign_rhs_code (stmt) == CONSTRUCTOR
> > > -       && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (stmt)) == 0
> > > +      if (initializer_zerop (gimple_op (stmt, 1), NULL)
> > >         && !gimple_clobber_p (stmt))
> > >       dse_optimize_redundant_stores (stmt);
> > >
> >
> > In addition to Jeff's comment, the original choice of gimple_assign_rhs1
> > is the preferred way to write this (applies to both hunks).
>
> And the !gimple_clobber_p test is now redundant.
>
> > Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DSE-2.patch
Type: text/x-patch
Size: 3194 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190813/6b867506/attachment.bin>


More information about the Gcc-patches mailing list