https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108603
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>: https://gcc.gnu.org/g:caecd24e230c4727c88ad117bab0342f378e81f7 commit r12-9380-gcaecd24e230c4727c88ad117bab0342f378e81f7 Author: Richard Sandiford <richard.sandif...@arm.com> Date: Mon Apr 3 09:57:07 2023 +0100 Avoid creating (const (reg ...)) [PR108603] convert_memory_address_addr_space_1 has two modes: one in which it tries to create a self-contained RTL expression (which might fail) and one in which it can emit new instructions where necessary. When handling a CONST, the function recurses into the CONST's operand and then constifies the result. But that's only valid if the result is still a self-contained expression. If new instructions have been emitted, the expression will refer to the (non-constant) results of those instructions. In the PR, this caused us to emit a nonsensical (const (reg ...)) REG_EQUAL note. gcc/ PR tree-optimization/108603 * explow.cc (convert_memory_address_addr_space_1): Only wrap the result of a recursive call in a CONST if no instructions were emitted. gcc/testsuite/ PR tree-optimization/108603 * gcc.target/aarch64/sve/pr108603.c: New test. (cherry picked from commit b09dc74801cf4e19bdf5fcd18a5cd53fc9e9ca9a)