diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-10-16 22:51:58 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-10-16 22:51:58 +0000 |
| commit | 4df59a9ff8363e78e9cd69727fe53d0e58b78903 (patch) | |
| tree | 3f04f995061b40767a8b2eceeaaf124e3019006f /llvm/lib/CodeGen/LiveRangeEdit.cpp | |
| parent | 2043329e675a7735dca72781ea21b062d611b5fc (diff) | |
| download | bcm5719-llvm-4df59a9ff8363e78e9cd69727fe53d0e58b78903.tar.gz bcm5719-llvm-4df59a9ff8363e78e9cd69727fe53d0e58b78903.zip | |
Avoid rematerializing a redef immediately after the old def.
PR14098 contains an example where we would rematerialize a MOV8ri
immediately after the original instruction:
%vreg7:sub_8bit<def> = MOV8ri 9; GR32_ABCD:%vreg7
%vreg22:sub_8bit<def> = MOV8ri 9; GR32_ABCD:%vreg7
Besides being pointless, it is also wrong since the original instruction
only redefines part of the register, and the value read by the new
instruction is wrong.
The problem was the LiveRangeEdit::allUsesAvailableAt() didn't
special-case OrigIdx == UseIdx and found the wrong SSA value.
llvm-svn: 166068
Diffstat (limited to 'llvm/lib/CodeGen/LiveRangeEdit.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LiveRangeEdit.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp index 0dfb084f1e1..f8fbc7ddf0c 100644 --- a/llvm/lib/CodeGen/LiveRangeEdit.cpp +++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp @@ -96,6 +96,13 @@ bool LiveRangeEdit::allUsesAvailableAt(const MachineInstr *OrigMI, const VNInfo *OVNI = li.getVNInfoAt(OrigIdx); if (!OVNI) continue; + + // Don't allow rematerialization immediately after the original def. + // It would be incorrect if OrigMI redefines the register. + // See PR14098. + if (SlotIndex::isSameInstr(OrigIdx, UseIdx)) + return false; + if (OVNI != li.getVNInfoAt(UseIdx)) return false; } |

