Index: lib/Target/AMDGPU/GCNHazardRecognizer.cpp =================================================================== --- lib/Target/AMDGPU/GCNHazardRecognizer.cpp +++ lib/Target/AMDGPU/GCNHazardRecognizer.cpp @@ -341,16 +341,7 @@ auto IsHazardDefFn = [this] (MachineInstr *MI) { return TII.isVALU(*MI); }; auto IsBufferHazardDefFn = [this] (MachineInstr *MI) { return TII.isSALU(*MI); }; - bool IsBufferSMRD = SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORD_IMM || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX16_IMM || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORD_SGPR || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR || - SMRD->getOpcode() == AMDGPU::S_BUFFER_LOAD_DWORDX16_SGPR; + bool IsBufferSMRD = TII.isBufferSMRD(*SMRD); for (const MachineOperand &Use : SMRD->uses()) { if (!Use.isReg()) Index: lib/Target/AMDGPU/SIInstrInfo.h =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.h +++ lib/Target/AMDGPU/SIInstrInfo.h @@ -416,6 +416,19 @@ return get(Opcode).TSFlags & SIInstrFlags::SMRD; } + bool isBufferSMRD(const MachineInstr &MI) const { + if (!isSMRD(MI)) + return false; + + // Check that it is using a buffer resource. + int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), AMDGPU::OpName::sbase); + if (Idx == -1) // e.g. s_memtime + return false; + + const auto RCID = MI.getDesc().OpInfo[Idx].RegClass; + return RCID == AMDGPU::SReg_128RegClassID; + } + static bool isDS(const MachineInstr &MI) { return MI.getDesc().TSFlags & SIInstrFlags::DS; }