Skip to content

Commit 909a048

Browse files
committed
Remove checks on vreg class
1 parent fdf2e00 commit 909a048

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,13 @@ class AMDGPURewriteAGPRCopyMFMAImpl {
7474
if (!PhysReg)
7575
return MCRegister();
7676

77-
const TargetRegisterClass *VirtRegRC = MRI.getRegClass(VReg);
78-
if (!TRI.hasAGPRs(VirtRegRC))
79-
return MCRegister();
80-
81-
if (!TRI.hasVGPRs(VirtRegRC))
82-
return PhysReg;
83-
8477
// If this is an AV register, we have to check if the actual assignment is
8578
// to an AGPR
8679
const TargetRegisterClass *AssignedRC = TRI.getPhysRegBaseClass(PhysReg);
8780
return TRI.isAGPRClass(AssignedRC) ? PhysReg : MCRegister();
8881
}
8982

90-
bool tryReassigningMFMAChain(MachineInstr &MFMA, unsigned HintOpIdx,
83+
bool tryReassigningMFMAChain(MachineInstr &MFMA, Register MFMAHintReg,
9184
MCPhysReg PhysRegHint) const;
9285

9386
/// Compute the register class constraints based on the uses of \p Reg,
@@ -187,13 +180,12 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::recomputeRegClassExceptRewritable(
187180
}
188181

189182
bool AMDGPURewriteAGPRCopyMFMAImpl::tryReassigningMFMAChain(
190-
MachineInstr &MFMA, unsigned HintOpIdx, MCPhysReg PhysRegHint) const {
183+
MachineInstr &MFMA, Register MFMAHintReg, MCPhysReg PhysRegHint) const {
191184
// src2 and dst have the same physical class constraint; try to preserve
192185
// the original src2 subclass if one were to exist.
193186
SmallVector<MachineInstr *, 4> RewriteCandidates = {&MFMA};
194187
SmallSetVector<Register, 4> RewriteRegs;
195188

196-
Register MFMAHintReg = MFMA.getOperand(HintOpIdx).getReg();
197189
// Make sure we reassign the MFMA we found the copy from first. We want
198190
// to ensure dst ends up in the physreg we were originally copying to.
199191
RewriteRegs.insert(MFMAHintReg);
@@ -352,7 +344,8 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::tryFoldCopiesToAGPR(
352344

353345
for (MachineInstr &CopySrcDefMI : MRI.def_instructions(CopySrcReg)) {
354346
if (isRewriteCandidate(CopySrcDefMI) &&
355-
tryReassigningMFMAChain(CopySrcDefMI, 0, AssignedAGPR))
347+
tryReassigningMFMAChain(
348+
CopySrcDefMI, CopySrcDefMI.getOperand(0).getReg(), AssignedAGPR))
356349
MadeChange = true;
357350
}
358351
}
@@ -380,10 +373,8 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::tryFoldCopiesFromAGPR(
380373

381374
for (MachineInstr &CopyUseMI : MRI.use_instructions(CopyDstReg)) {
382375
if (isRewriteCandidate(CopyUseMI)) {
383-
const MachineOperand *Op =
384-
CopyUseMI.findRegisterUseOperand(CopyDstReg, /*TRI=*/nullptr);
385-
if (tryReassigningMFMAChain(CopyUseMI, Op->getOperandNo(),
386-
VRM.getPhys(Op->getReg())))
376+
if (tryReassigningMFMAChain(CopyUseMI, CopyDstReg,
377+
VRM.getPhys(CopyDstReg)))
387378
MadeChange = true;
388379
}
389380
}

0 commit comments

Comments
 (0)