Just like we already do with undef flags, we need to drop kill flags if
they aren't present in all merged instructions. Otherwise we would merge
<instr1> $r0 <instr2> killed $r0
and
<instr1> killed $r0 <instr2> undef $r0
into
<instr1> killed $r0 <instr2> $r0
and then the verifier would complain about $r0 not being live at <instr2>.
Similarly, we need to drop dead flags if they aren't present in all
merged instructions. Otherwise we would merge
dead $r0 = <instr1> <instr2> undef $r0
and
$r0 = <instr1> <instr2> $r0
into
dead $r0 = <instr1> <instr2> $r0
and then the verifier would complain about $r0 not being live at <instr2>.
Afaict this isn't consistent with the mirrored situation (if MO says "undef" and OtherMO says "killed") the result will be that "undef" is dropped, but not an addition of "killed".
I think the result should be the same regardless of which bb that use as a base for the merge. Shouldn't it?
Btw, is there a problem with simply clearing the killed flag unless it is set in both operands?
(I'm not sure if an undef implies killed today. Or if it that might change in the future when the freeze stuff has been implemented. In your example above instr2 is a def, but I assume it could be a use as well, that could be undef, or maybe even a use of the same undef value as used in instr1.)