https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111019
--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:c1b5514124ab7a8aceec1ae4a82d2149fc687ecf commit r13-7753-gc1b5514124ab7a8aceec1ae4a82d2149fc687ecf Author: Richard Biener <rguent...@suse.de> Date: Thu Aug 17 15:21:33 2023 +0200 tree-optimization/111019 - invariant motion and aliasing The following fixes a bad choice in representing things to the alias oracle by LIM which while correct in pieces is inconsistent with itself. When canonicalizing a ref to a bare deref instead of leaving the base object and the extracted offset the same and just substituting an alternate ref the following replaces the base and the offset as well, avoiding the confusion that otherwise will arise in aliasing_matching_component_refs_p. PR tree-optimization/111019 * tree-ssa-loop-im.cc (gather_mem_refs_stmt): When canonicalizing also scrap base and offset in case the ref is indirect. * g++.dg/torture/pr111019.C: New testcase. (cherry picked from commit 745ec2135aabfbe2c0fb7780309837d17e8986d4)