If the register named in an existing REG_UNUSED note dies somewhere
between where the note used to be and I3, we should just drop it.
2021-04-21 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/99927
* combine.c (distribute_notes) [REG_UNUSED]: If the register already
is dead, just drop it.
we keep notes from i2 or i1 if they will turn into REG_DEAD
notes. */
+ /* If this register is set or clobbered between FROM_INSN and I3,
+ we should not create a note for it. */
+ if (reg_set_between_p (XEXP (note, 0), from_insn, i3))
+ break;
+
/* If this register is set or clobbered in I3, put the note there
unless there is one already. */
if (reg_set_p (XEXP (note, 0), PATTERN (i3)))