https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69274
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> --- Alternate fix not causing PR69689 (but also not getting the extra speedup observed with the original fix): Index: gcc/ira.c =================================================================== --- gcc/ira.c (revision 233172) +++ gcc/ira.c (working copy) @@ -1774,7 +1774,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG int nop, nalt; bool curr_swapped; const char *p; - int commutative = -1; + int commutative = -1, alt_commutative = -1; extract_insn (insn); alternative_mask preferred = get_preferred_alternatives (insn); @@ -1838,6 +1838,8 @@ ira_setup_alts (rtx_insn *insn, HARD_REG case '%': /* The commutative modifier is handled above. */ + if (alt_commutative < 0) + alt_commutative = nop; break; case '0': case '1': case '2': case '3': case '4': @@ -1889,10 +1891,13 @@ ira_setup_alts (rtx_insn *insn, HARD_REG } if (commutative < 0) break; + /* Swap forth and back to avoid changing recog_data. */ + if (! curr_swapped + || alt_commutative < 0) + std::swap (recog_data.operand[commutative], + recog_data.operand[commutative + 1]); if (curr_swapped) break; - std::swap (recog_data.operand[commutative], - recog_data.operand[commutative + 1]); } }