https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115629
--- Comment #2 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:629257bcb81434117f1e9c68479032563176dc0c commit r15-1662-g629257bcb81434117f1e9c68479032563176dc0c Author: Richard Biener <rguent...@suse.de> Date: Tue Jun 25 14:04:31 2024 +0200 tree-optimization/115629 - missed tail merging The following fixes a missed tail-merging observed for the testcase in PR115629. The issue is that when deps_ok_for_redirect doesn't compute both would be valid prevailing blocks it rejects the merge. The following instead makes sure to record the working block as prevailing. Also stmt comparison fails for indirect references and is not handling memory references thoroughly, failing to unify array indices and pointers indirected. The following attempts to fix this. PR tree-optimization/115629 * tree-ssa-tail-merge.cc (gimple_equal_p): Handle memory references better. (deps_ok_for_redirect): Handle the case not both blocks are considered a valid prevailing block. * gcc.dg/tree-ssa/tail-merge-1.c: New testcase.