https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111019
--- Comment #10 from CVS 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:745ec2135aabfbe2c0fb7780309837d17e8986d4 commit r14-3325-g745ec2135aabfbe2c0fb7780309837d17e8986d4 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.