On Fri, Aug 1, 2025 at 9:01 PM Andrew Pinski <quic_apin...@quicinc.com> wrote:
>
> This is version 2 of the following patches:
> https://inbox.sourceware.org/gcc-patches/20250608175102.1476184-1-quic_apin...@quicinc.com/
> https://inbox.sourceware.org/gcc-patches/20250609061323.1772598-1-quic_apin...@quicinc.com/T/#u
>
> For the memset patch, I had forgot to include the limit for the walker.
> This has now been added back and some minor formating issues has been fixed.
> The first one is unchanged; see below for stats.
>
> The other 2 patches here are a bug fix for non-call exceptions and an
> improvement dealing with zeroing case; recognizing integer zero stores
> like a memset of zero (also vector and complex zeros).
>
> As I mentioned the first patch makes it easier to prop not just into other
> copy statements but into arguments and returns and even the possibility of
> handling partial loads in the future.
>
> As far as stats are concerned, the current copy prop for aggregates and this 
> one,
> does not change code generation in many cases. Though this is only because 
> SRA was
> handling these cases. Now what I have seen is in heavily C++ code, the number 
> of decls
> created have decreased significantly. For an example while compiling 
> highway's benchmark
> code, the number of decls created decreased over 2000; this is because SRA 
> does not need
> to do a full scalarization for many of the copies.
> Also the places where this has improved code generation is SRA is not doing 
> full scalarization
> which made things worse.

Just an FYI, I found a bug in the second patch of this patch set. Well
the bug there is on the trunk; I don't know if it affects anything.
The bug is in the creation of ao_ref for the memset (memcpy on the
trunk). Since ao_ref_init is used on the ADDR_EXPR; the size could be
wrong. Though I can't find a testcase for the new forward code, I did
find one for backwards version, filed as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121422 .

Thanks,
Andrew Pinski


>
>
>
> Andrew Pinski (4):
>   forwprop: Change optimize_agr_copyprop into forward walk instead of
>     backwards
>   forwprop: Change proping memset into memcpy into a forwprop rather
>     than a backwalk
>   forwprop: Don't do copy-prop-aggregates from statements that could
>     throw [PR120599]
>   forwprop: Recongize a store of integral zero for
>     optimize_aggr_zeroprop.
>
>  gcc/testsuite/g++.dg/torture/noncall-eh-1.C   |  26 ++
>  gcc/testsuite/gcc.dg/pr118946-1.c             |  15 +
>  .../gcc.dg/torture/copy-prop-aggr-zero-1.c    |  28 ++
>  .../gcc.dg/torture/copy-prop-aggr-zero-2.c    |  28 ++
>  .../tree-ssa/copy-prop-aggregate-zero-1.c     |  28 ++
>  .../tree-ssa/copy-prop-aggregate-zero-2.c     |  25 ++
>  .../tree-ssa/copy-prop-aggregate-zero-3.c     |  25 ++
>  gcc/tree-ssa-forwprop.cc                      | 425 ++++++++++--------
>  8 files changed, 413 insertions(+), 187 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/torture/noncall-eh-1.C
>  create mode 100644 gcc/testsuite/gcc.dg/pr118946-1.c
>  create mode 100644 gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c
>  create mode 100644 gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c
>
> --
> 2.43.0
>

Reply via email to