Revision 220239 exposed a latent bug in method 'TargetInstrInfo::commuteInstruction'.
When commuting the operands of a machine instruction, method 'commuteInstruction' doesn't correctly propagate the 'IsUndef' flag to the register operands of the new (commuted) instruction.
Before this patch, the following instruction:
%vreg4<def> = VADDSDrr %vreg14, %vreg5<undef>; FR64:%vreg4,%vreg14,%vreg5
was wrongly converted by method 'commuteInstruction' into:
%vreg4<def> = VADDSDrr %vreg5, %vreg14<undef>; FR64:%vreg4,%vreg5,%vreg14
The correct instruction should have been:
%vreg4<def> = VADDSDrr %vreg5<undef>, %vreg14; FR64:%vreg4,%vreg5,%vreg14
This patch fixes the problem in method 'TargetInstrInfo::commuteInstruction'. When swapping the operands of a machine instruction, we now make sure that 'IsUndef' flags are correctly set.
This fixes PR23103.
Added test case 'pr23103.ll' (obtained from the reproducible posted in PR23103).
Please let me know if ok to submit.
Thanks,
Andrea