From: Philipp Tomsich Date: Fri, 6 Mar 2026 09:54:13 +0000 (+0100) Subject: ext-dce: Only remove REG_EQUAL/EQUIV notes on successful optimization X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a82d2c6816ff9f3afce67a6cb3cd5d8fe0f9af5d;p=thirdparty%2Fgcc.git ext-dce: Only remove REG_EQUAL/EQUIV notes on successful optimization 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. --- diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc index 5cc15dd9b44..d0b49241a4b 100644 --- a/gcc/ext-dce.cc +++ b/gcc/ext-dce.cc @@ -519,7 +519,8 @@ ext_dce_try_optimize_extension (rtx_insn *insn, rtx set) /* 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 {