diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp --- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -678,7 +678,7 @@ setRegScore(RegNo + NUM_ALL_VGPRS, t, CurrScore); } #endif - } else { + } else /* LGKM_CNT || EXP_CNT || VS_CNT || NUM_INST_CNTS */{ // Match the score to the destination registers. for (unsigned I = 0, E = Inst.getNumOperands(); I != E; ++I) { auto &Op = Inst.getOperand(I); @@ -689,6 +689,10 @@ if (Interval.first >= NUM_ALL_VGPRS) continue; if (updateVMCntOnly(Inst)) { + // updateVMCntOnly should only leave us with VGPRs + // MUBUF, MTBUF, MIMG, FlatGlobal, and FlatScratch only have VGPR + // defs. That's required for a sane index into `VgprMemTypes` below + assert(TRI->isVGPR(*MRI, Op.getReg())); VmemType V = getVmemType(Inst); for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo) VgprVmemTypes[RegNo] |= 1 << V;