Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUPrepareAGPRAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ using namespace llvm;

#define DEBUG_TYPE "amdgpu-prepare-agpr-alloc"

static cl::opt<bool> InflateToAVClass(
"amdgpu-avgpr-inflation", cl::Hidden,
cl::desc("Whether to inflate register to the avgpr register "
"class -- which is assignable to either vgpr or agpr."),
cl::init(false));

namespace {

class AMDGPUPrepareAGPRAllocImpl {
Expand Down Expand Up @@ -97,6 +103,8 @@ bool AMDGPUPrepareAGPRAllocImpl::run(MachineFunction &MF) {

const MCInstrDesc &AVImmPseudo32 = TII.get(AMDGPU::AV_MOV_B32_IMM_PSEUDO);
const MCInstrDesc &AVImmPseudo64 = TII.get(AMDGPU::AV_MOV_B64_IMM_PSEUDO);
const SIRegisterInfo *TRI =
static_cast<const SIRegisterInfo *>(MRI.getTargetRegisterInfo());

bool Changed = false;
for (MachineBasicBlock &MBB : MF) {
Expand All @@ -119,6 +127,23 @@ bool AMDGPUPrepareAGPRAllocImpl::run(MachineFunction &MF) {
Changed = true;
continue;
}

if (!InflateToAVClass)
continue;

for (MachineOperand &Op : MI.operands()) {
if (!Op.isReg() || !Op.isDef())
continue;

Register DefReg = Op.getReg();
if (DefReg.isPhysical())
continue;

const TargetRegisterClass *RC = MRI.getRegClass(DefReg);

if (TRI->hasVectorRegisters(RC))
Changed |= MRI.recomputeRegClass(DefReg);
}
}
}

Expand Down
Loading