https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92176
Bug ID: 92176 Summary: LRA problem with reloads for subreg operands Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Target Milestone: --- Created attachment 47083 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47083&action=edit reduced testcase The attached testcase core dumps when compiled with -O3 -march=z13 but executes fine with -O3 -march=zEC12. A QImode subreg on a pseudo gets assigned a floating point register and is simplified to (reg:QI (...)). However, changing the mode of an FPR is disallowed by the S/390 backend in s390_can_change_mode class. The problem appears to be that simplify_operand_subreg in lra-constraints.c does not check can_change_mode_class before assigning a register class. It always picks the preferred register class for an expression as returned by the backend. reload used to invoke can_change_mode_class when reloading a subreg - see push_reload. I tried to return just GENERAL_REGS in the preferred_reload_class whenever being invoked with a subreg for which can_change_mode class would return false. This helps in some cases. However, that function does not always get called with the subreg expression, if there are other uses of that register not having a subreg.