Skip to content

Commit

Permalink
AMDGPU/GlobalISel: Remove getVRegDef null checks in selector (llvm#11…
Browse files Browse the repository at this point in the history
…5530)

We should be able to assume every virtual register is defined.
  • Loading branch information
arsenm authored and pull[bot] committed Nov 18, 2024
1 parent 49341f5 commit 1406152
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3839,7 +3839,7 @@ AMDGPUInstructionSelector::selectVOP3PModsImpl(
unsigned Mods = 0;
MachineInstr *MI = MRI.getVRegDef(Src);

if (MI && MI->getOpcode() == AMDGPU::G_FNEG &&
if (MI->getOpcode() == AMDGPU::G_FNEG &&
// It's possible to see an f32 fneg here, but unlikely.
// TODO: Treat f32 fneg as only high bit.
MRI.getType(Src) == LLT::fixed_vector(2, 16)) {
Expand Down Expand Up @@ -4662,24 +4662,24 @@ AMDGPUInstructionSelector::selectMUBUFScratchOffen(MachineOperand &Root) const {
// offsets.
std::optional<int> FI;
Register VAddr = Root.getReg();
if (const MachineInstr *RootDef = MRI->getVRegDef(Root.getReg())) {
Register PtrBase;
int64_t ConstOffset;
std::tie(PtrBase, ConstOffset) = getPtrBaseWithConstantOffset(VAddr, *MRI);
if (ConstOffset != 0) {
if (TII.isLegalMUBUFImmOffset(ConstOffset) &&
(!STI.privateMemoryResourceIsRangeChecked() ||
KB->signBitIsZero(PtrBase))) {
const MachineInstr *PtrBaseDef = MRI->getVRegDef(PtrBase);
if (PtrBaseDef->getOpcode() == AMDGPU::G_FRAME_INDEX)
FI = PtrBaseDef->getOperand(1).getIndex();
else
VAddr = PtrBase;
Offset = ConstOffset;
}
} else if (RootDef->getOpcode() == AMDGPU::G_FRAME_INDEX) {
FI = RootDef->getOperand(1).getIndex();

const MachineInstr *RootDef = MRI->getVRegDef(Root.getReg());
Register PtrBase;
int64_t ConstOffset;
std::tie(PtrBase, ConstOffset) = getPtrBaseWithConstantOffset(VAddr, *MRI);
if (ConstOffset != 0) {
if (TII.isLegalMUBUFImmOffset(ConstOffset) &&
(!STI.privateMemoryResourceIsRangeChecked() ||
KB->signBitIsZero(PtrBase))) {
const MachineInstr *PtrBaseDef = MRI->getVRegDef(PtrBase);
if (PtrBaseDef->getOpcode() == AMDGPU::G_FRAME_INDEX)
FI = PtrBaseDef->getOperand(1).getIndex();
else
VAddr = PtrBase;
Offset = ConstOffset;
}
} else if (RootDef->getOpcode() == AMDGPU::G_FRAME_INDEX) {
FI = RootDef->getOperand(1).getIndex();
}

return {{[=](MachineInstrBuilder &MIB) { // rsrc
Expand Down Expand Up @@ -4901,9 +4901,6 @@ AMDGPUInstructionSelector::selectMUBUFScratchOffset(
std::pair<Register, unsigned>
AMDGPUInstructionSelector::selectDS1Addr1OffsetImpl(MachineOperand &Root) const {
const MachineInstr *RootDef = MRI->getVRegDef(Root.getReg());
if (!RootDef)
return std::pair(Root.getReg(), 0);

int64_t ConstAddr = 0;

Register PtrBase;
Expand Down Expand Up @@ -4966,9 +4963,6 @@ std::pair<Register, unsigned>
AMDGPUInstructionSelector::selectDSReadWrite2Impl(MachineOperand &Root,
unsigned Size) const {
const MachineInstr *RootDef = MRI->getVRegDef(Root.getReg());
if (!RootDef)
return std::pair(Root.getReg(), 0);

int64_t ConstAddr = 0;

Register PtrBase;
Expand Down

0 comments on commit 1406152

Please sign in to comment.