]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/99954 - redo loop distribution memcpy recognition fix
authorRichard Biener <rguenther@suse.de>
Tue, 14 May 2024 09:13:51 +0000 (11:13 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 14 May 2024 17:00:27 +0000 (19:00 +0200)
commitc290e6a0b7a9de5692963affc6627a4af7dc2411
treef7b8f3cda47d4876fa4d6318f1ed559e40fe3b99
parent54ba8d44bbd703bca6984700b4d6f978890097e2
tree-optimization/99954 - redo loop distribution memcpy recognition fix

The following revisits the fix for PR99954 which was observed as
causing missed memcpy recognition and instead using memmove for
non-aliasing copies.  While the original fix mitigated bogus
recognition of memcpy the root cause was not properly identified.
The root cause is dr_analyze_indices "failing" to handle union
references and leaving the DRs indices in a state that's not correctly
handled by dr_may_alias.  The following mitigates this there
appropriately, restoring memcpy recognition for non-aliasing copies.

This makes us run into a latent issue in ptr_deref_may_alias_decl_p
when the pointer is something like &MEM[0].a in which case we fail
to handle non-SSA name pointers.  Add code similar to what we have
in ptr_derefs_may_alias_p.

PR tree-optimization/99954
* tree-data-ref.cc (dr_may_alias_p): For bases that are
not completely analyzed fall back to TBAA and points-to.
* tree-loop-distribution.cc
(loop_distribution::classify_builtin_ldst): When there
is no dependence again classify as memcpy.
* tree-ssa-alias.cc (ptr_deref_may_alias_decl_p): Verify
the pointer is an SSA name.

* gcc.dg/tree-ssa/ldist-40.c: New testcase.
gcc/testsuite/gcc.dg/tree-ssa/ldist-40.c [new file with mode: 0644]
gcc/tree-data-ref.cc
gcc/tree-loop-distribution.cc
gcc/tree-ssa-alias.cc