https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79279
Bug ID: 79279 Summary: combine/simplify_set: wrong call to REG_CANNOT_CHANGE_MODE_P Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: aurelien.buhrig.gcc at gmail dot com Target Milestone: --- Created attachment 40619 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40619&action=edit patch In simplify_set, when trying to generate paradoxical subregs of hard regs, a call to REG_CANNOT_CHANGE_MODE_P enables checking if the new mode is valid. In fact, changing from (set x:m1 (subreg:m1 (op:m2))) to (set (subreg:m2 x) op2) is valid if REG_CANNOT_CHANGE_MODE_P (REGNO(x), FROM=m1, TO=m2) is false. Currently, FROM and TO parameters are switched, leading in wrong combination of sub words paradoxical subregs (private target backend): Currently: && REG_CANNOT_CHANGE_MODE_P (REGNO (dest), GET_MODE (SUBREG_REG (src)), GET_MODE (src))) Should be: && REG_CANNOT_CHANGE_MODE_P (REGNO (dest), GET_MODE (src), GET_MODE (SUBREG_REG (src)))) See attached patch.