https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124041
--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Robin Dapp <[email protected]>: https://gcc.gnu.org/g:4bcf6c461a9b8fb6e68de3f0b695881b9ac6e934 commit r16-7891-g4bcf6c461a9b8fb6e68de3f0b695881b9ac6e934 Author: Robin Dapp <[email protected]> Date: Wed Mar 4 10:02:07 2026 +0100 lra: Validate regno and mode in equiv substitution. [PR124041] We can perform equivalence substitution in subreg context: (insn 34 32 36 3 (set (reg:SI 103 [ _7 ]) (subreg:SI (reg/f:DI 119) 0)) "bla.c":7:41 104 {*movsi_aarch64} becomes (insn 34 32 36 3 (set (reg:SI 103 [ _7 ]) (subreg:SI (reg/f:DI 64 sfp) 0)) "bla.c":7:41 104 {*movsi_aarch64} (nil)) but aarch64_hard_regno_mode_ok doesn't like that: if (regno == FRAME_POINTER_REGNUM || regno == ARG_POINTER_REGNUM) return mode == Pmode; and ICEs further on. Therefore, this patch checks hard_regno_mode_ok if we substitute a hard reg in subreg context. PR rtl-optimization/124041 gcc/ChangeLog: * lra-constraints.cc (curr_insn_transform): Check if hardreg is valid in subreg context. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr124041.c: New test. Signed-off-by: Robin Dapp <[email protected]>
