]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ext-dce: Only remove REG_EQUAL/EQUIV notes on successful optimization
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Fri, 6 Mar 2026 09:54:13 +0000 (10:54 +0100)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Mon, 27 Apr 2026 21:07:41 +0000 (23:07 +0200)
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.

gcc/ext-dce.cc

index 5cc15dd9b44f4d786f89d13afa8e7208db2e7fd3..d0b49241a4bbcd651e75ce2d47d163eec4b1725a 100644 (file)
@@ -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
     {