forked from OSchip/llvm-project
[CriticalAntiDepBreaker] Teach the regmask clobber check to check if any subregister is preserved before considering the super register clobbered
X86 has some calling conventions where bits 127:0 of a vector register are callee saved, but the upper bits aren't. Previously we could detect that the full ymm register was clobbered when the xmm portion was really preserved. This patch checks the subregisters to make sure they aren't preserved. Fixes PR44140 Differential Revision: https://reviews.llvm.org/D70699
This commit is contained in:
parent
5d21f75b57
commit
9283681e16
|
@ -261,15 +261,25 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
|
||||||
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MI.getOperand(i);
|
MachineOperand &MO = MI.getOperand(i);
|
||||||
|
|
||||||
if (MO.isRegMask())
|
if (MO.isRegMask()) {
|
||||||
for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i)
|
auto ClobbersPhysRegAndSubRegs = [&](unsigned PhysReg) {
|
||||||
if (MO.clobbersPhysReg(i)) {
|
for (MCSubRegIterator SRI(PhysReg, TRI, true); SRI.isValid(); ++SRI)
|
||||||
|
if (!MO.clobbersPhysReg(*SRI))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) {
|
||||||
|
if (ClobbersPhysRegAndSubRegs(i)) {
|
||||||
DefIndices[i] = Count;
|
DefIndices[i] = Count;
|
||||||
KillIndices[i] = ~0u;
|
KillIndices[i] = ~0u;
|
||||||
KeepRegs.reset(i);
|
KeepRegs.reset(i);
|
||||||
Classes[i] = nullptr;
|
Classes[i] = nullptr;
|
||||||
RegRefs.erase(i);
|
RegRefs.erase(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!MO.isReg()) continue;
|
if (!MO.isReg()) continue;
|
||||||
Register Reg = MO.getReg();
|
Register Reg = MO.getReg();
|
||||||
|
|
|
@ -10,7 +10,6 @@ define win64cc void @opaque() {
|
||||||
|
|
||||||
; We need xmm6 to be live from the loop header across all iterations of the loop.
|
; We need xmm6 to be live from the loop header across all iterations of the loop.
|
||||||
; We shouldn't clobber ymm6 inside the loop.
|
; We shouldn't clobber ymm6 inside the loop.
|
||||||
; FIXME: We currently clobber ymm6
|
|
||||||
define i32 @main() {
|
define i32 @main() {
|
||||||
; CHECK-LABEL: main:
|
; CHECK-LABEL: main:
|
||||||
; CHECK: # %bb.0: # %start
|
; CHECK: # %bb.0: # %start
|
||||||
|
@ -23,7 +22,7 @@ define i32 @main() {
|
||||||
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
|
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
|
||||||
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm0
|
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm0
|
||||||
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm1
|
; 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), %ymm2
|
||||||
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm3
|
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm3
|
||||||
; CHECK-NEXT: vmovups %ymm0, {{[0-9]+}}(%rsp)
|
; CHECK-NEXT: vmovups %ymm0, {{[0-9]+}}(%rsp)
|
||||||
|
@ -31,10 +30,10 @@ define i32 @main() {
|
||||||
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm1
|
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm1
|
||||||
; CHECK-NEXT: vmovups %ymm3, {{[0-9]+}}(%rsp)
|
; CHECK-NEXT: vmovups %ymm3, {{[0-9]+}}(%rsp)
|
||||||
; CHECK-NEXT: vmovups %ymm2, {{[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 %ymm3, {{[0-9]+}}(%rsp)
|
||||||
; CHECK-NEXT: vmovups %ymm2, {{[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 %ymm1, {{[0-9]+}}(%rsp)
|
; CHECK-NEXT: vmovups %ymm1, {{[0-9]+}}(%rsp)
|
||||||
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm5
|
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %ymm5
|
||||||
|
|
Loading…
Reference in New Issue