1 //===-- GCNHazardRecognizers.cpp - GCN Hazard Recognizer Impls ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements hazard recognizers for scheduling on GCN processors.
12 //===----------------------------------------------------------------------===//
14 #include "GCNHazardRecognizer.h"
15 #include "AMDGPUSubtarget.h"
16 #include "SIDefines.h"
17 #include "SIInstrInfo.h"
18 #include "SIRegisterInfo.h"
19 #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
20 #include "Utils/AMDGPUBaseInfo.h"
21 #include "llvm/ADT/iterator_range.h"
22 #include "llvm/CodeGen/MachineFunction.h"
23 #include "llvm/CodeGen/MachineInstr.h"
24 #include "llvm/CodeGen/MachineOperand.h"
25 #include "llvm/CodeGen/ScheduleDAG.h"
26 #include "llvm/MC/MCInstrDesc.h"
27 #include "llvm/Support/ErrorHandling.h"
36 //===----------------------------------------------------------------------===//
37 // Hazard Recoginizer Implementation
38 //===----------------------------------------------------------------------===//
40 GCNHazardRecognizer::GCNHazardRecognizer(const MachineFunction &MF) :
41 CurrCycleInstr(nullptr),
43 ST(MF.getSubtarget<GCNSubtarget>()),
44 TII(*ST.getInstrInfo()),
45 TRI(TII.getRegisterInfo()),
46 ClauseUses(TRI.getNumRegUnits()),
47 ClauseDefs(TRI.getNumRegUnits()) {
51 void GCNHazardRecognizer::EmitInstruction(SUnit *SU) {
52 EmitInstruction(SU->getInstr());
55 void GCNHazardRecognizer::EmitInstruction(MachineInstr *MI) {
59 static bool isDivFMas(unsigned Opcode) {
60 return Opcode == AMDGPU::V_DIV_FMAS_F32 || Opcode == AMDGPU::V_DIV_FMAS_F64;
63 static bool isSGetReg(unsigned Opcode) {
64 return Opcode == AMDGPU::S_GETREG_B32;
67 static bool isSSetReg(unsigned Opcode) {
68 return Opcode == AMDGPU::S_SETREG_B32 || Opcode == AMDGPU::S_SETREG_IMM32_B32;
71 static bool isRWLane(unsigned Opcode) {
72 return Opcode == AMDGPU::V_READLANE_B32 || Opcode == AMDGPU::V_WRITELANE_B32;
75 static bool isRFE(unsigned Opcode) {
76 return Opcode == AMDGPU::S_RFE_B64;
79 static bool isSMovRel(unsigned Opcode) {
81 case AMDGPU::S_MOVRELS_B32:
82 case AMDGPU::S_MOVRELS_B64:
83 case AMDGPU::S_MOVRELD_B32:
84 case AMDGPU::S_MOVRELD_B64:
91 static bool isSendMsgTraceDataOrGDS(const MachineInstr &MI) {
92 switch (MI.getOpcode()) {
93 case AMDGPU::S_SENDMSG:
94 case AMDGPU::S_SENDMSGHALT:
95 case AMDGPU::S_TTRACEDATA:
103 static unsigned getHWReg(const SIInstrInfo *TII, const MachineInstr &RegInstr) {
104 const MachineOperand *RegOp = TII->getNamedOperand(RegInstr,
105 AMDGPU::OpName::simm16);
106 return RegOp->getImm() & AMDGPU::Hwreg::ID_MASK_;
109 ScheduleHazardRecognizer::HazardType
110 GCNHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
111 MachineInstr *MI = SU->getInstr();
113 if (SIInstrInfo::isSMRD(*MI) && checkSMRDHazards(MI) > 0)
116 // FIXME: Should flat be considered vmem?
117 if ((SIInstrInfo::isVMEM(*MI) ||
118 SIInstrInfo::isFLAT(*MI))
119 && checkVMEMHazards(MI) > 0)
122 if (SIInstrInfo::isVALU(*MI) && checkVALUHazards(MI) > 0)
125 if (SIInstrInfo::isDPP(*MI) && checkDPPHazards(MI) > 0)
128 if (isDivFMas(MI->getOpcode()) && checkDivFMasHazards(MI) > 0)
131 if (isRWLane(MI->getOpcode()) && checkRWLaneHazards(MI) > 0)
134 if (isSGetReg(MI->getOpcode()) && checkGetRegHazards(MI) > 0)
137 if (isSSetReg(MI->getOpcode()) && checkSetRegHazards(MI) > 0)
140 if (isRFE(MI->getOpcode()) && checkRFEHazards(MI) > 0)
143 if (ST.hasReadM0MovRelInterpHazard() &&
144 (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode())) &&
145 checkReadM0Hazards(MI) > 0)
148 if (ST.hasReadM0SendMsgHazard() && isSendMsgTraceDataOrGDS(*MI) &&
149 checkReadM0Hazards(MI) > 0)
152 if (MI->isInlineAsm() && checkInlineAsmHazards(MI) > 0)
155 if (checkAnyInstHazards(MI) > 0)
161 unsigned GCNHazardRecognizer::PreEmitNoops(SUnit *SU) {
162 return PreEmitNoops(SU->getInstr());
165 unsigned GCNHazardRecognizer::PreEmitNoops(MachineInstr *MI) {
166 int WaitStates = std::max(0, checkAnyInstHazards(MI));
168 if (SIInstrInfo::isSMRD(*MI))
169 return std::max(WaitStates, checkSMRDHazards(MI));
171 if (SIInstrInfo::isVALU(*MI))
172 WaitStates = std::max(WaitStates, checkVALUHazards(MI));
174 if (SIInstrInfo::isVMEM(*MI) || SIInstrInfo::isFLAT(*MI))
175 WaitStates = std::max(WaitStates, checkVMEMHazards(MI));
177 if (SIInstrInfo::isDPP(*MI))
178 WaitStates = std::max(WaitStates, checkDPPHazards(MI));
180 if (isDivFMas(MI->getOpcode()))
181 WaitStates = std::max(WaitStates, checkDivFMasHazards(MI));
183 if (isRWLane(MI->getOpcode()))
184 WaitStates = std::max(WaitStates, checkRWLaneHazards(MI));
186 if (MI->isInlineAsm())
187 return std::max(WaitStates, checkInlineAsmHazards(MI));
189 if (isSGetReg(MI->getOpcode()))
190 return std::max(WaitStates, checkGetRegHazards(MI));
192 if (isSSetReg(MI->getOpcode()))
193 return std::max(WaitStates, checkSetRegHazards(MI));
195 if (isRFE(MI->getOpcode()))
196 return std::max(WaitStates, checkRFEHazards(MI));
198 if (ST.hasReadM0MovRelInterpHazard() && (TII.isVINTRP(*MI) ||
199 isSMovRel(MI->getOpcode())))
200 return std::max(WaitStates, checkReadM0Hazards(MI));
202 if (ST.hasReadM0SendMsgHazard() && isSendMsgTraceDataOrGDS(*MI))
203 return std::max(WaitStates, checkReadM0Hazards(MI));
208 void GCNHazardRecognizer::EmitNoop() {
209 EmittedInstrs.push_front(nullptr);
212 void GCNHazardRecognizer::AdvanceCycle() {
213 // When the scheduler detects a stall, it will call AdvanceCycle() without
214 // emitting any instructions.
218 unsigned NumWaitStates = TII.getNumWaitStates(*CurrCycleInstr);
220 // Keep track of emitted instructions
221 EmittedInstrs.push_front(CurrCycleInstr);
223 // Add a nullptr for each additional wait state after the first. Make sure
224 // not to add more than getMaxLookAhead() items to the list, since we
225 // truncate the list to that size right after this loop.
226 for (unsigned i = 1, e = std::min(NumWaitStates, getMaxLookAhead());
228 EmittedInstrs.push_front(nullptr);
231 // getMaxLookahead() is the largest number of wait states we will ever need
232 // to insert, so there is no point in keeping track of more than that many
234 EmittedInstrs.resize(getMaxLookAhead());
236 CurrCycleInstr = nullptr;
239 void GCNHazardRecognizer::RecedeCycle() {
240 llvm_unreachable("hazard recognizer does not support bottom-up scheduling.");
243 //===----------------------------------------------------------------------===//
245 //===----------------------------------------------------------------------===//
247 int GCNHazardRecognizer::getWaitStatesSince(
248 function_ref<bool(MachineInstr *)> IsHazard) {
250 for (MachineInstr *MI : EmittedInstrs) {
255 unsigned Opcode = MI->getOpcode();
256 if (Opcode == AMDGPU::DBG_VALUE || Opcode == AMDGPU::IMPLICIT_DEF ||
257 Opcode == AMDGPU::INLINEASM)
262 return std::numeric_limits<int>::max();
265 int GCNHazardRecognizer::getWaitStatesSinceDef(
266 unsigned Reg, function_ref<bool(MachineInstr *)> IsHazardDef) {
267 const SIRegisterInfo *TRI = ST.getRegisterInfo();
269 auto IsHazardFn = [IsHazardDef, TRI, Reg] (MachineInstr *MI) {
270 return IsHazardDef(MI) && MI->modifiesRegister(Reg, TRI);
273 return getWaitStatesSince(IsHazardFn);
276 int GCNHazardRecognizer::getWaitStatesSinceSetReg(
277 function_ref<bool(MachineInstr *)> IsHazard) {
278 auto IsHazardFn = [IsHazard] (MachineInstr *MI) {
279 return isSSetReg(MI->getOpcode()) && IsHazard(MI);
282 return getWaitStatesSince(IsHazardFn);
285 //===----------------------------------------------------------------------===//
286 // No-op Hazard Detection
287 //===----------------------------------------------------------------------===//
289 static void addRegUnits(const SIRegisterInfo &TRI,
290 BitVector &BV, unsigned Reg) {
291 for (MCRegUnitIterator RUI(Reg, &TRI); RUI.isValid(); ++RUI)
295 static void addRegsToSet(const SIRegisterInfo &TRI,
296 iterator_range<MachineInstr::const_mop_iterator> Ops,
298 for (const MachineOperand &Op : Ops) {
300 addRegUnits(TRI, Set, Op.getReg());
304 void GCNHazardRecognizer::addClauseInst(const MachineInstr &MI) {
305 // XXX: Do we need to worry about implicit operands
306 addRegsToSet(TRI, MI.defs(), ClauseDefs);
307 addRegsToSet(TRI, MI.uses(), ClauseUses);
310 int GCNHazardRecognizer::checkSoftClauseHazards(MachineInstr *MEM) {
311 // SMEM soft clause are only present on VI+, and only matter if xnack is
313 if (!ST.isXNACKEnabled())
316 bool IsSMRD = TII.isSMRD(*MEM);
320 // A soft-clause is any group of consecutive SMEM instructions. The
321 // instructions in this group may return out of order and/or may be
322 // replayed (i.e. the same instruction issued more than once).
324 // In order to handle these situations correctly we need to make sure
325 // that when a clause has more than one instruction, no instruction in the
326 // clause writes to a register that is read another instruction in the clause
327 // (including itself). If we encounter this situaion, we need to break the
328 // clause by inserting a non SMEM instruction.
330 for (MachineInstr *MI : EmittedInstrs) {
331 // When we hit a non-SMEM instruction then we have passed the start of the
332 // clause and we can stop.
336 if (IsSMRD != SIInstrInfo::isSMRD(*MI))
342 if (ClauseDefs.none())
345 // We need to make sure not to put loads and stores in the same clause if they
346 // use the same address. For now, just start a new clause whenever we see a
353 // If the set of defs and uses intersect then we cannot add this instruction
354 // to the clause, so we have a hazard.
355 return ClauseDefs.anyCommon(ClauseUses) ? 1 : 0;
358 int GCNHazardRecognizer::checkSMRDHazards(MachineInstr *SMRD) {
359 const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
360 int WaitStatesNeeded = 0;
362 WaitStatesNeeded = checkSoftClauseHazards(SMRD);
364 // This SMRD hazard only affects SI.
365 if (ST.getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS)
366 return WaitStatesNeeded;
368 // A read of an SGPR by SMRD instruction requires 4 wait states when the
369 // SGPR was written by a VALU instruction.
370 int SmrdSgprWaitStates = 4;
371 auto IsHazardDefFn = [this] (MachineInstr *MI) { return TII.isVALU(*MI); };
372 auto IsBufferHazardDefFn = [this] (MachineInstr *MI) { return TII.isSALU(*MI); };
374 bool IsBufferSMRD = TII.isBufferSMRD(*SMRD);
376 for (const MachineOperand &Use : SMRD->uses()) {
379 int WaitStatesNeededForUse =
380 SmrdSgprWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardDefFn);
381 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
383 // This fixes what appears to be undocumented hardware behavior in SI where
384 // s_mov writing a descriptor and s_buffer_load_dword reading the descriptor
385 // needs some number of nops in between. We don't know how many we need, but
386 // let's use 4. This wasn't discovered before probably because the only
387 // case when this happens is when we expand a 64-bit pointer into a full
388 // descriptor and use s_buffer_load_dword instead of s_load_dword, which was
389 // probably never encountered in the closed-source land.
391 int WaitStatesNeededForUse =
392 SmrdSgprWaitStates - getWaitStatesSinceDef(Use.getReg(),
393 IsBufferHazardDefFn);
394 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
398 return WaitStatesNeeded;
401 int GCNHazardRecognizer::checkVMEMHazards(MachineInstr* VMEM) {
402 if (ST.getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS)
405 int WaitStatesNeeded = checkSoftClauseHazards(VMEM);
407 // A read of an SGPR by a VMEM instruction requires 5 wait states when the
408 // SGPR was written by a VALU Instruction.
409 const int VmemSgprWaitStates = 5;
410 auto IsHazardDefFn = [this] (MachineInstr *MI) { return TII.isVALU(*MI); };
412 for (const MachineOperand &Use : VMEM->uses()) {
413 if (!Use.isReg() || TRI.isVGPR(MF.getRegInfo(), Use.getReg()))
416 int WaitStatesNeededForUse =
417 VmemSgprWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardDefFn);
418 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
420 return WaitStatesNeeded;
423 int GCNHazardRecognizer::checkDPPHazards(MachineInstr *DPP) {
424 const SIRegisterInfo *TRI = ST.getRegisterInfo();
425 const SIInstrInfo *TII = ST.getInstrInfo();
427 // Check for DPP VGPR read after VALU VGPR write and EXEC write.
428 int DppVgprWaitStates = 2;
429 int DppExecWaitStates = 5;
430 int WaitStatesNeeded = 0;
431 auto IsHazardDefFn = [TII] (MachineInstr *MI) { return TII->isVALU(*MI); };
433 for (const MachineOperand &Use : DPP->uses()) {
434 if (!Use.isReg() || !TRI->isVGPR(MF.getRegInfo(), Use.getReg()))
436 int WaitStatesNeededForUse =
437 DppVgprWaitStates - getWaitStatesSinceDef(Use.getReg());
438 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
441 WaitStatesNeeded = std::max(
443 DppExecWaitStates - getWaitStatesSinceDef(AMDGPU::EXEC, IsHazardDefFn));
445 return WaitStatesNeeded;
448 int GCNHazardRecognizer::checkDivFMasHazards(MachineInstr *DivFMas) {
449 const SIInstrInfo *TII = ST.getInstrInfo();
451 // v_div_fmas requires 4 wait states after a write to vcc from a VALU
453 const int DivFMasWaitStates = 4;
454 auto IsHazardDefFn = [TII] (MachineInstr *MI) { return TII->isVALU(*MI); };
455 int WaitStatesNeeded = getWaitStatesSinceDef(AMDGPU::VCC, IsHazardDefFn);
457 return DivFMasWaitStates - WaitStatesNeeded;
460 int GCNHazardRecognizer::checkGetRegHazards(MachineInstr *GetRegInstr) {
461 const SIInstrInfo *TII = ST.getInstrInfo();
462 unsigned GetRegHWReg = getHWReg(TII, *GetRegInstr);
464 const int GetRegWaitStates = 2;
465 auto IsHazardFn = [TII, GetRegHWReg] (MachineInstr *MI) {
466 return GetRegHWReg == getHWReg(TII, *MI);
468 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
470 return GetRegWaitStates - WaitStatesNeeded;
473 int GCNHazardRecognizer::checkSetRegHazards(MachineInstr *SetRegInstr) {
474 const SIInstrInfo *TII = ST.getInstrInfo();
475 unsigned HWReg = getHWReg(TII, *SetRegInstr);
477 const int SetRegWaitStates =
478 ST.getGeneration() <= AMDGPUSubtarget::SEA_ISLANDS ? 1 : 2;
479 auto IsHazardFn = [TII, HWReg] (MachineInstr *MI) {
480 return HWReg == getHWReg(TII, *MI);
482 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
483 return SetRegWaitStates - WaitStatesNeeded;
486 int GCNHazardRecognizer::createsVALUHazard(const MachineInstr &MI) {
490 const SIInstrInfo *TII = ST.getInstrInfo();
491 unsigned Opcode = MI.getOpcode();
492 const MCInstrDesc &Desc = MI.getDesc();
494 int VDataIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdata);
497 VDataRCID = Desc.OpInfo[VDataIdx].RegClass;
499 if (TII->isMUBUF(MI) || TII->isMTBUF(MI)) {
500 // There is no hazard if the instruction does not use vector regs
504 // For MUBUF/MTBUF instructions this hazard only exists if the
505 // instruction is not using a register in the soffset field.
506 const MachineOperand *SOffset =
507 TII->getNamedOperand(MI, AMDGPU::OpName::soffset);
508 // If we have no soffset operand, then assume this field has been
509 // hardcoded to zero.
510 if (AMDGPU::getRegBitWidth(VDataRCID) > 64 &&
511 (!SOffset || !SOffset->isReg()))
515 // MIMG instructions create a hazard if they don't use a 256-bit T# and
516 // the store size is greater than 8 bytes and they have more than two bits
517 // of their dmask set.
518 // All our MIMG definitions use a 256-bit T#, so we can skip checking for them.
519 if (TII->isMIMG(MI)) {
520 int SRsrcIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::srsrc);
521 assert(SRsrcIdx != -1 &&
522 AMDGPU::getRegBitWidth(Desc.OpInfo[SRsrcIdx].RegClass) == 256);
526 if (TII->isFLAT(MI)) {
527 int DataIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdata);
528 if (AMDGPU::getRegBitWidth(Desc.OpInfo[DataIdx].RegClass) > 64)
535 int GCNHazardRecognizer::checkVALUHazardsHelper(const MachineOperand &Def,
536 const MachineRegisterInfo &MRI) {
537 // Helper to check for the hazard where VMEM instructions that store more than
538 // 8 bytes can have there store data over written by the next instruction.
539 const SIRegisterInfo *TRI = ST.getRegisterInfo();
541 const int VALUWaitStates = 1;
542 int WaitStatesNeeded = 0;
544 if (!TRI->isVGPR(MRI, Def.getReg()))
545 return WaitStatesNeeded;
546 unsigned Reg = Def.getReg();
547 auto IsHazardFn = [this, Reg, TRI] (MachineInstr *MI) {
548 int DataIdx = createsVALUHazard(*MI);
549 return DataIdx >= 0 &&
550 TRI->regsOverlap(MI->getOperand(DataIdx).getReg(), Reg);
552 int WaitStatesNeededForDef =
553 VALUWaitStates - getWaitStatesSince(IsHazardFn);
554 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForDef);
556 return WaitStatesNeeded;
559 int GCNHazardRecognizer::checkVALUHazards(MachineInstr *VALU) {
560 // This checks for the hazard where VMEM instructions that store more than
561 // 8 bytes can have there store data over written by the next instruction.
562 if (!ST.has12DWordStoreHazard())
565 const MachineRegisterInfo &MRI = MF.getRegInfo();
566 int WaitStatesNeeded = 0;
568 for (const MachineOperand &Def : VALU->defs()) {
569 WaitStatesNeeded = std::max(WaitStatesNeeded, checkVALUHazardsHelper(Def, MRI));
572 return WaitStatesNeeded;
575 int GCNHazardRecognizer::checkInlineAsmHazards(MachineInstr *IA) {
576 // This checks for hazards associated with inline asm statements.
577 // Since inline asms can contain just about anything, we use this
578 // to call/leverage other check*Hazard routines. Note that
579 // this function doesn't attempt to address all possible inline asm
580 // hazards (good luck), but is a collection of what has been
581 // problematic thus far.
583 // see checkVALUHazards()
584 if (!ST.has12DWordStoreHazard())
587 const MachineRegisterInfo &MRI = MF.getRegInfo();
588 int WaitStatesNeeded = 0;
590 for (unsigned I = InlineAsm::MIOp_FirstOperand, E = IA->getNumOperands();
592 const MachineOperand &Op = IA->getOperand(I);
593 if (Op.isReg() && Op.isDef()) {
594 WaitStatesNeeded = std::max(WaitStatesNeeded, checkVALUHazardsHelper(Op, MRI));
598 return WaitStatesNeeded;
601 int GCNHazardRecognizer::checkRWLaneHazards(MachineInstr *RWLane) {
602 const SIInstrInfo *TII = ST.getInstrInfo();
603 const SIRegisterInfo *TRI = ST.getRegisterInfo();
604 const MachineRegisterInfo &MRI = MF.getRegInfo();
606 const MachineOperand *LaneSelectOp =
607 TII->getNamedOperand(*RWLane, AMDGPU::OpName::src1);
609 if (!LaneSelectOp->isReg() || !TRI->isSGPRReg(MRI, LaneSelectOp->getReg()))
612 unsigned LaneSelectReg = LaneSelectOp->getReg();
613 auto IsHazardFn = [TII] (MachineInstr *MI) {
614 return TII->isVALU(*MI);
617 const int RWLaneWaitStates = 4;
618 int WaitStatesSince = getWaitStatesSinceDef(LaneSelectReg, IsHazardFn);
619 return RWLaneWaitStates - WaitStatesSince;
622 int GCNHazardRecognizer::checkRFEHazards(MachineInstr *RFE) {
623 if (ST.getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS)
626 const SIInstrInfo *TII = ST.getInstrInfo();
628 const int RFEWaitStates = 1;
630 auto IsHazardFn = [TII] (MachineInstr *MI) {
631 return getHWReg(TII, *MI) == AMDGPU::Hwreg::ID_TRAPSTS;
633 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
634 return RFEWaitStates - WaitStatesNeeded;
637 int GCNHazardRecognizer::checkAnyInstHazards(MachineInstr *MI) {
638 if (MI->isDebugInstr())
641 const SIRegisterInfo *TRI = ST.getRegisterInfo();
642 if (!ST.hasSMovFedHazard())
645 // Check for any instruction reading an SGPR after a write from
647 int MovFedWaitStates = 1;
648 int WaitStatesNeeded = 0;
650 for (const MachineOperand &Use : MI->uses()) {
651 if (!Use.isReg() || TRI->isVGPR(MF.getRegInfo(), Use.getReg()))
653 auto IsHazardFn = [] (MachineInstr *MI) {
654 return MI->getOpcode() == AMDGPU::S_MOV_FED_B32;
656 int WaitStatesNeededForUse =
657 MovFedWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardFn);
658 WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
661 return WaitStatesNeeded;
664 int GCNHazardRecognizer::checkReadM0Hazards(MachineInstr *MI) {
665 const SIInstrInfo *TII = ST.getInstrInfo();
666 const int SMovRelWaitStates = 1;
667 auto IsHazardFn = [TII] (MachineInstr *MI) {
668 return TII->isSALU(*MI);
670 return SMovRelWaitStates - getWaitStatesSinceDef(AMDGPU::M0, IsHazardFn);