[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)
commit796d906e06f8f5a3c8d4f5f0faa5c47697153490
tree91cbf0e3c4865d79254dadb6cf1347ae9ab7ff57
parented75e7aecea674529b2d4400ea19d9ca227e2979
[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.

llvm-svn: 235647
llvm/lib/CodeGen/MachineCopyPropagation.cpp
llvm/test/CodeGen/X86/copy-propagation.ll [new file with mode: 0644]