@@ -119,6 +119,11 @@ enum : VMEMID {
119119 NUM_LDSDMA = TRACKINGID_RANGE_LEN
120120};
121121
122+ // / Convert a MCRegUnit to a VMEMID.
123+ static constexpr VMEMID toVMEMID (MCRegUnit RU) {
124+ return static_cast <unsigned >(RU);
125+ }
126+
122127struct HardwareLimits {
123128 unsigned LoadcntMax; // Corresponds to VMcnt prior to gfx12.
124129 unsigned ExpcntMax;
@@ -685,7 +690,7 @@ class WaitcntBrackets {
685690 // instructions with types different from V.
686691 bool hasOtherPendingVmemTypes (MCPhysReg Reg, VmemType V) const {
687692 for (MCRegUnit RU : regunits (Reg)) {
688- auto It = VMem.find (RU );
693+ auto It = VMem.find (toVMEMID (RU) );
689694 if (It != VMem.end () && (It->second .VMEMTypes & ~(1 << V)))
690695 return true ;
691696 }
@@ -694,7 +699,7 @@ class WaitcntBrackets {
694699
695700 void clearVgprVmemTypes (MCPhysReg Reg) {
696701 for (MCRegUnit RU : regunits (Reg)) {
697- if (auto It = VMem.find (RU ); It != VMem.end ())
702+ if (auto It = VMem.find (toVMEMID (RU) ); It != VMem.end ())
698703 It->second .VMEMTypes = 0 ;
699704 }
700705 }
@@ -763,7 +768,7 @@ class WaitcntBrackets {
763768 SCCScore = Val;
764769 } else if (TRI->isVectorRegister (*Context->MRI , Reg)) {
765770 for (MCRegUnit RU : regunits (Reg))
766- VMem[RU ].Scores [T] = Val;
771+ VMem[toVMEMID (RU) ].Scores [T] = Val;
767772 } else if (TRI->isSGPRReg (*Context->MRI , Reg)) {
768773 auto STy = getSgprScoresIdx (T);
769774 for (MCRegUnit RU : regunits (Reg))
@@ -1009,7 +1014,7 @@ void WaitcntBrackets::updateByEvent(WaitEventType E, MachineInstr &Inst) {
10091014 if (hasPointSampleAccel (Inst))
10101015 TypesMask |= 1 << VMEM_NOSAMPLER;
10111016 for (MCRegUnit RU : regunits (Op.getReg ().asMCReg ()))
1012- VMem[RU ].VMEMTypes |= TypesMask;
1017+ VMem[toVMEMID (RU) ].VMEMTypes |= TypesMask;
10131018 }
10141019 }
10151020 setScoreByOperand (Op, T, CurrScore);
@@ -1126,7 +1131,7 @@ void WaitcntBrackets::print(raw_ostream &OS) const {
11261131 if (RegScore <= LB)
11271132 continue ;
11281133 unsigned RelScore = RegScore - LB - 1 ;
1129- OS << RelScore << " :sRU" << ID << " " ;
1134+ OS << RelScore << " :sRU" << static_cast < unsigned >(ID) << " " ;
11301135 }
11311136 }
11321137
@@ -1211,7 +1216,8 @@ void WaitcntBrackets::determineWaitForPhysReg(InstCounterType T, MCPhysReg Reg,
12111216 bool IsVGPR = Context->TRI ->isVectorRegister (*Context->MRI , Reg);
12121217 for (MCRegUnit RU : regunits (Reg))
12131218 determineWaitForScore (
1214- T, IsVGPR ? getVMemScore (RU, T) : getSGPRScore (RU, T), Wait);
1219+ T, IsVGPR ? getVMemScore (toVMEMID (RU), T) : getSGPRScore (RU, T),
1220+ Wait);
12151221 }
12161222}
12171223
@@ -2633,11 +2639,12 @@ bool SIInsertWaitcnts::shouldFlushVmCnt(MachineLoop *ML,
26332639 VgprUse.insert (RU);
26342640 // If at least one of Op's registers is in the score brackets, the
26352641 // value is likely loaded outside of the loop.
2636- if (Brackets.getVMemScore (RU, LOAD_CNT) >
2642+ unsigned ID = toVMEMID (RU);
2643+ if (Brackets.getVMemScore (ID, LOAD_CNT) >
26372644 Brackets.getScoreLB (LOAD_CNT) ||
2638- Brackets.getVMemScore (RU , SAMPLE_CNT) >
2645+ Brackets.getVMemScore (ID , SAMPLE_CNT) >
26392646 Brackets.getScoreLB (SAMPLE_CNT) ||
2640- Brackets.getVMemScore (RU , BVH_CNT) >
2647+ Brackets.getVMemScore (ID , BVH_CNT) >
26412648 Brackets.getScoreLB (BVH_CNT)) {
26422649 UsesVgprLoadedOutside = true ;
26432650 break ;
0 commit comments