when cse replaces registers in an insn it tries to avoid calls to
validate_change, what causes trouble in some situations.
From validate_canon_reg:
/* If replacing pseudo with hard reg or vice versa, ensure the
insn remains valid. Likewise if the insn has MATCH_DUPs. */
if (insn != 0 && new != 0
&& REG_P (new) && REG_P (*xloc)
&& (((REGNO (new) < FIRST_PSEUDO_REGISTER)
!= (REGNO (*xloc) < FIRST_PSEUDO_REGISTER))
|| GET_MODE (new) != GET_MODE (*xloc)
|| (insn_code = recog_memoized (insn)) < 0
|| insn_data[insn_code].n_dups > 0))
validate_change (insn, xloc, new, 1);
else
*xloc = new;