Skip to content

Commit

Permalink
[AMDGPU] SIInstrInfo::verifyInstruction tweaks. NFCI.
Browse files Browse the repository at this point in the history
Simplify some for loops. Don't bother checking src2 operand for
writelane because it doesn't have one. Check all VALU instructions,
not just VOP1/2/3/C/SDWA.
  • Loading branch information
jayfoad committed Mar 21, 2022
1 parent 31486a9 commit 321d3aa
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4134,9 +4134,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,

int DstIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdst);

const int OpIndices[] = {DstIdx, Src0Idx, Src1Idx, Src2Idx};

for (int OpIdx : OpIndices) {
for (int OpIdx : {DstIdx, Src0Idx, Src1Idx, Src2Idx}) {
if (OpIdx == -1)
continue;
const MachineOperand &MO = MI.getOperand(OpIdx);
Expand Down Expand Up @@ -4253,13 +4251,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
}

// Verify VOP*. Ignore multiple sgpr operands on writelane.
if (Desc.getOpcode() != AMDGPU::V_WRITELANE_B32
&& (isVOP1(MI) || isVOP2(MI) || isVOP3(MI) || isVOPC(MI) || isSDWA(MI))) {
// Only look at the true operands. Only a real operand can use the constant
// bus, and we don't want to check pseudo-operands like the source modifier
// flags.
const int OpIndices[] = { Src0Idx, Src1Idx, Src2Idx };

if (isVALU(MI) && Desc.getOpcode() != AMDGPU::V_WRITELANE_B32) {
unsigned ConstantBusCount = 0;
bool UsesLiteral = false;
const MachineOperand *LiteralVal = nullptr;
Expand All @@ -4270,7 +4262,10 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
SmallVector<Register, 2> SGPRsUsed;
Register SGPRUsed;

for (int OpIdx : OpIndices) {
// Only look at the true operands. Only a real operand can use the constant
// bus, and we don't want to check pseudo-operands like the source modifier
// flags.
for (int OpIdx : {Src0Idx, Src1Idx, Src2Idx}) {
if (OpIdx == -1)
break;
const MachineOperand &MO = MI.getOperand(OpIdx);
Expand Down Expand Up @@ -4328,7 +4323,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
unsigned SGPRCount = 0;
Register SGPRUsed = AMDGPU::NoRegister;

for (int OpIdx : {Src0Idx, Src1Idx, Src2Idx}) {
for (int OpIdx : {Src0Idx, Src1Idx}) {
if (OpIdx == -1)
break;

Expand Down Expand Up @@ -4580,7 +4575,6 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
}

int DstIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdst);
int Src0Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src0);

if (Opcode != AMDGPU::V_MOV_B64_DPP_PSEUDO &&
((DstIdx >= 0 &&
Expand Down

0 comments on commit 321d3aa

Please sign in to comment.