This is version 3 of the patches: https://inbox.sourceware.org/gcc-patches/20250802035048.3815303-1-quic_apin...@quicinc.com/T/#m757887289de93b288be742132f9a56a9c3812514
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. It also includes a fix for the aliasing walk and a 2 new testcases for that. 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. The last (new) patch includes the copying into arguments. 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. Andrew Pinski (5): 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. forwprop: Copy prop aggregates into args 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 ++ gcc/testsuite/gcc.dg/torture/pr121422-1.c | 35 ++ gcc/testsuite/gcc.dg/torture/pr121422-2.c | 36 ++ .../tree-ssa/copy-prop-aggregate-arg-1.c | 21 + .../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 | 453 +++++++++++------- 11 files changed, 556 insertions(+), 164 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/torture/pr121422-1.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr121422-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.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