https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99954
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:c290e6a0b7a9de5692963affc6627a4af7dc2411 commit r15-491-gc290e6a0b7a9de5692963affc6627a4af7dc2411 Author: Richard Biener <rguent...@suse.de> Date: Tue May 14 11:13:51 2024 +0200 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.