In ext_dce_try_optimize_extension, REG_EQUAL/EQUIV notes were removed
unconditionally after attempting validate_change, even when the
validation failed and the insn was reverted to its original state.
This could cause subsequent passes to generate different (incorrect)
code because they lost the REG_EQUAL hint on an unchanged insn.
Guard the note removal with the 'ok' flag so notes are only stripped
when validate_change actually committed the transformation.
gcc/ChangeLog:
* ext-dce.cc (ext_dce_try_optimize_extension): Only remove
REG_EQUAL/EQUIV notes when validate_change succeeds.
/* INSN may have a REG_EQUAL note indicating that the value was
sign or zero extended. That note is no longer valid since we've
just removed the extension. Just wipe the notes. */
- remove_reg_equal_equiv_notes (insn, false);
+ if (ok)
+ remove_reg_equal_equiv_notes (insn, false);
}
else
{