Skip to content

Commit c0498f8

Browse files
committed
Don't delete apparent no-op if src==def is a reserved reg
1 parent d209c13 commit c0498f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,11 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
973973

974974
// It's possible that the previous transformation has resulted in a no-op
975975
// register move (i.e. one where source and destination registers are the
976-
// same). If so, delete it.
976+
// same and are not referring to a reserved register). If so, delete it.
977977
CopyOperands = isCopyInstr(MI, *TII, UseCopyInstr);
978978
if (CopyOperands &&
979-
CopyOperands->Source->getReg() == CopyOperands->Destination->getReg()) {
979+
CopyOperands->Source->getReg() == CopyOperands->Destination->getReg() &&
980+
!MRI->isReserved(CopyOperands->Source->getReg())) {
980981
MI.eraseFromParent();
981982
NumDeletes++;
982983
Changed = true;

0 commit comments

Comments
 (0)