diff --git a/llvm/lib/Target/X86/X86ExpandPseudo.cpp b/llvm/lib/Target/X86/X86ExpandPseudo.cpp index d9c0964e9ed834..b1d15225eaaf1f 100644 --- a/llvm/lib/Target/X86/X86ExpandPseudo.cpp +++ b/llvm/lib/Target/X86/X86ExpandPseudo.cpp @@ -346,7 +346,9 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB, // Copy the input argument of the pseudo into the argument of the // actual instruction. - TII->copyPhysReg(MBB, MBBI, DL, X86::RBX, InArg.getReg(), InArg.isKill()); + // NOTE: We don't copy the kill flag since the input might be the same reg + // as one of the other operands of LCMPXCHG16B. + TII->copyPhysReg(MBB, MBBI, DL, X86::RBX, InArg.getReg(), false); // Create the actual instruction. MachineInstr *NewInstr = BuildMI(MBB, MBBI, DL, TII->get(X86::LCMPXCHG16B)); // Copy the operands related to the address. diff --git a/llvm/test/CodeGen/X86/pr42064.ll b/llvm/test/CodeGen/X86/pr42064.ll index 6269a59ff055e6..089895da18a1df 100644 --- a/llvm/test/CodeGen/X86/pr42064.ll +++ b/llvm/test/CodeGen/X86/pr42064.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc19.11.0 -mattr=+avx,+cx16 | FileCheck %s +; RUN: llc < %s -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc19.11.0 -mattr=+avx,+cx16 | FileCheck %s %struct.TestStruct = type { %union.Int128 } %union.Int128 = type { i128 }