diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index ff75b87b23128..9e82b5caed0d0 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -1200,7 +1200,7 @@ void MachineCopyPropagation::BackwardCopyPropagateBlock( // Ignore non-trivial COPYs. std::optional CopyOperands = isCopyInstr(MI, *TII, UseCopyInstr); - if (CopyOperands) { + if (CopyOperands && MI.getNumImplicitOperands() == 0) { Register DefReg = CopyOperands->Destination->getReg(); Register SrcReg = CopyOperands->Source->getReg(); diff --git a/llvm/test/CodeGen/SystemZ/pr137687.mir b/llvm/test/CodeGen/SystemZ/pr137687.mir new file mode 100644 index 0000000000000..66038f9dce22f --- /dev/null +++ b/llvm/test/CodeGen/SystemZ/pr137687.mir @@ -0,0 +1,21 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 +# RUN: llc %s -mtriple=s390x-unknown-linux-gnu -run-pass=machine-cp -verify-machineinstrs -o - | FileCheck %s + +--- +name: t +tracksRegLiveness: true +noPhis: true +isSSA: false +noVRegs: true +hasFakeUses: false +tracksDebugUserValues: true +body: | + bb.0: + ; CHECK-LABEL: name: t + ; CHECK: renamable $r14d = LLILL 0 + ; CHECK-NEXT: renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q + ; CHECK-NEXT: Return implicit $r12q + renamable $r14d = LLILL 0 + renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q + Return implicit $r12q +...