]> git.ipfire.org Git - thirdparty/gcc.git/commit
forwprop: Handle memcpy for arguments with respect to copies
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 10 Sep 2025 22:53:41 +0000 (15:53 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 17 Sep 2025 18:35:39 +0000 (11:35 -0700)
commit09e1ba1cc0f62afaec1e768843fc5e055da14a23
tree75e87007bf447baea5f15afbde191a81ab182be8
parent3268c47c08782efe7fb1dd9a110bebe018e7d59c
forwprop: Handle memcpy for arguments with respect to copies

This moves the code used in optimize_agr_copyprop_1 (r16-3887-g597b50abb0d)
to handle this same case into its new function and use it inside
optimize_agr_copyprop_arg. This allows to remove more copies that show up only
in arguments.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Split out
the case where `operand_equal_p (dest, src2)` is false into ...
(new_src_based_on_copy): This. New function.
(optimize_agr_copyprop_arg): Use new_src_based_on_copy
instead of operand_equal_p to find the new src.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc