[MachineCopyPropagation] Handle undef flags conservatively so that we do not
authorQuentin Colombet <qcolombet@apple.com>
Thu, 23 Apr 2015 21:17:39 +0000 (21:17 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Thu, 23 Apr 2015 21:17:39 +0000 (21:17 +0000)
commitc364314ec3143d8c323e006ea588168a3b3516d5
tree248228394ddfe3b799594e19a822d8b0cb56ceee
parent9ed816ae52d7435a7894ff79dc4118127782c0a7
[MachineCopyPropagation] Handle undef flags conservatively so that we do not
remove copies that are useful after breaking some hardware dependencies.
In other words, handle this kind of situations conservatively by assuming reg2
is redefined by the undef flag.
reg1 = copy reg2
= inst reg2<undef>
reg2 = copy reg1
Copy propagation used to remove the last copy.
This is incorrect because the undef flag on reg2 in inst, allows next
passes to put whatever trashed value in reg2 that may help.
In practice we end up with this code:
reg1 = copy reg2
reg2 = 0
= inst reg2<undef>
reg2 = copy reg1

This fixes PR21743.

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