[Bug tree-optimization/121422] [16 Regression] wrong code for proping zero incorrectly
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 8 21:31:33 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121422
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:899e7284bfa0b736165c3d9d5c18d5d883c5cbfb
commit r16-3094-g899e7284bfa0b736165c3d9d5c18d5d883c5cbfb
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date: Sun Jun 8 23:13:23 2025 -0700
forwprop: Change proping memset into memcpy into a forwprop rather than a
backwalk
One thing I noticed while working on copy prop for aggregates is that we
start with
a memcpy like statement and then walk backwards. This means we could have a
few walks
backwards to see there was no statement for zeroing. Instead this changes
the walk
backwards into a true forwprop. In the future we can expand to forwprop the
zeroing
into say an function argument or something more than memcpy like statement.
This should speed up slightly the compile time performance since there will
be less
memsets like statements than memcpy and there is only one walk forwards for
memset like
staments instead of multiple walk backwards to find the memset.
Note this does add one extra improvement, the memcpy now does not need to
have an address
as its dest argument; this could have been done before too but it was even
more noticable
now because of the variable became only set so it was removed and the check
was removed
as well.
There is also a fix on how ao_ref for the memset/memcpy is done, before it
was just using
ao_ref_init which is wrong since it should instead of used
ao_ref_init_from_ptr_and_size.
This part fixes PR 121422.
Changes since v1:
* v2: Add back limit on the walk which was missed in v1.
Move the call to get_addr_base_and_unit_offset outside
of the vuse loop.
* v3: Remove extra check before the call to optimize_aggr_zeroprop_1.
Fix setting up of ao_ref for memset (PR121422).
PR tree-optimization/118946
PR tree-optimization/121422
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_memcpy_to_memset): Remove.
(optimize_aggr_zeroprop_1): New function.
(optimize_aggr_zeroprop): New function.
(simplify_builtin_call): Don't call optimize_memcpy_to_memset
for memcpy but call optimize_aggr_zeroprop for memset.
(pass_forwprop::execute): Don't call optimize_memcpy_to_memset
for aggregate copies but rather call optimize_aggr_zeroprop
for aggregate stores.
gcc/testsuite/ChangeLog:
* gcc.dg/pr118946-1.c: New test.
* gcc.dg/torture/pr121422-1.c: New test.
* gcc.dg/torture/pr121422-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
More information about the Gcc-bugs
mailing list