diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2015-04-23 21:17:39 +0000 |
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2015-04-23 21:17:39 +0000 |
| commit | 796d906e06f8f5a3c8d4f5f0faa5c47697153490 (patch) | |
| tree | 91cbf0e3c4865d79254dadb6cf1347ae9ab7ff57 /llvm/lib/CodeGen/MachineCopyPropagation.cpp | |
| parent | ed75e7aecea674529b2d4400ea19d9ca227e2979 (diff) | |
| download | bcm5719-llvm-796d906e06f8f5a3c8d4f5f0faa5c47697153490.tar.gz bcm5719-llvm-796d906e06f8f5a3c8d4f5f0faa5c47697153490.zip | |
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineCopyPropagation.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 96111225db5..43c80b7c21b 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -252,7 +252,11 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { report_fatal_error("MachineCopyPropagation should be run after" " register allocation!"); - if (MO.isDef()) { + // Treat undef use like defs. + // The backends are allowed to do whatever they want with undef value + // and we cannot be sure this register will not be rewritten to break + // some false dependencies for the hardware for instance. + if (MO.isDef() || MO.isUndef()) { Defs.push_back(Reg); continue; } |

