Index: llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp =================================================================== --- llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp +++ llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp @@ -261,15 +261,28 @@ for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); - if (MO.isRegMask()) - for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) + if (MO.isRegMask()) { + for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) { if (MO.clobbersPhysReg(i)) { - DefIndices[i] = Count; - KillIndices[i] = ~0u; - KeepRegs.reset(i); - Classes[i] = nullptr; - RegRefs.erase(i); + // Make sure all subregisters are also clobbered. + bool PreservesSubReg = false; + for (MCSubRegIterator SRI(i, TRI, true); SRI.isValid(); ++SRI) { + if (!MO.clobbersPhysReg(*SRI)) { + PreservesSubReg = true; + break; + } + } + + if (!PreservesSubReg) { + DefIndices[i] = Count; + KillIndices[i] = ~0u; + KeepRegs.reset(i); + Classes[i] = nullptr; + RegRefs.erase(i); + } } + } + } if (!MO.isReg()) continue; Register Reg = MO.getReg(); Index: llvm/test/CodeGen/X86/pr44140.ll =================================================================== --- llvm/test/CodeGen/X86/pr44140.ll +++ llvm/test/CodeGen/X86/pr44140.ll @@ -23,7 +23,7 @@ ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1 ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm0 ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm1 -; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm6 +; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm7 ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm2 ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm3 ; CHECK-NEXT: vmovups %ymm0, {{[0-9]+}}(%rsp) @@ -31,10 +31,10 @@ ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm1 ; CHECK-NEXT: vmovups %ymm3, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups %ymm2, {{[0-9]+}}(%rsp) -; CHECK-NEXT: vmovups %ymm6, {{[0-9]+}}(%rsp) +; CHECK-NEXT: vmovups %ymm7, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups %ymm3, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups %ymm2, {{[0-9]+}}(%rsp) -; CHECK-NEXT: vmovups %ymm6, {{[0-9]+}}(%rsp) +; CHECK-NEXT: vmovups %ymm7, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups %ymm1, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups %ymm1, {{[0-9]+}}(%rsp) ; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm5