Fix for PR23103. Correctly propagate the 'IsUndef' flag to the register operands...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 30 Apr 2015 21:03:29 +0000 (21:03 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 30 Apr 2015 21:03:29 +0000 (21:03 +0000)
commit3b156699381e266b8c620056c139b876524df2eb
tree69ba79c5473fe4c54671e49b6e47c732e5150359
parent494f112fbc67f053f2e11d0d1397da30c07d1a99
Fix for PR23103. Correctly propagate the 'IsUndef' flag to the register operands of a commuted instruction.

Revision 220239 exposed a latent bug in method
'TargetInstrInfo::commuteInstruction'. When commuting the operands of a machine
instruction, method 'commuteInstruction' didn'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.
Added test case 'pr23103.ll'.

Differential Revision: http://reviews.llvm.org/D9406

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236258 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/TargetInstrInfo.cpp
test/CodeGen/X86/pr23103.ll [new file with mode: 0644]