@@ -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;
@@ -678,7 +683,7 @@ class WaitcntBrackets {
678683 // instructions with types different from V.
679684 bool hasOtherPendingVmemTypes (MCPhysReg Reg, VmemType V) const {
680685 for (MCRegUnit RU : regunits (Reg)) {
681- auto It = VMem.find (RU );
686+ auto It = VMem.find (toVMEMID (RU) );
682687 if (It != VMem.end () && (It->second .VMEMTypes & ~(1 << V)))
683688 return true ;
684689 }
@@ -687,7 +692,7 @@ class WaitcntBrackets {
687692
688693 void clearVgprVmemTypes (MCPhysReg Reg) {
689694 for (MCRegUnit RU : regunits (Reg)) {
690- if (auto It = VMem.find (RU ); It != VMem.end ())
695+ if (auto It = VMem.find (toVMEMID (RU) ); It != VMem.end ())
691696 It->second .VMEMTypes = 0 ;
692697 }
693698 }
@@ -756,7 +761,7 @@ class WaitcntBrackets {
756761 SCCScore = Val;
757762 } else if (TRI->isVectorRegister (*Context->MRI , Reg)) {
758763 for (MCRegUnit RU : regunits (Reg))
759- VMem[RU ].Scores [T] = Val;
764+ VMem[toVMEMID (RU) ].Scores [T] = Val;
760765 } else if (TRI->isSGPRReg (*Context->MRI , Reg)) {
761766 auto STy = getSgprScoresIdx (T);
762767 for (MCRegUnit RU : regunits (Reg))
@@ -1003,7 +1008,7 @@ void WaitcntBrackets::updateByEvent(WaitEventType E, MachineInstr &Inst) {
10031008 if (hasPointSampleAccel (Inst))
10041009 TypesMask |= 1 << VMEM_NOSAMPLER;
10051010 for (MCRegUnit RU : regunits (Op.getReg ().asMCReg ()))
1006- VMem[RU ].VMEMTypes |= TypesMask;
1011+ VMem[toVMEMID (RU) ].VMEMTypes |= TypesMask;
10071012 }
10081013 }
10091014 setScoreByOperand (Op, T, CurrScore);
@@ -1123,7 +1128,7 @@ void WaitcntBrackets::print(raw_ostream &OS) const {
11231128 if (RegScore <= LB)
11241129 continue ;
11251130 unsigned RelScore = RegScore - LB - 1 ;
1126- OS << RelScore << " :sRU" << ID << " " ;
1131+ OS << RelScore << " :sRU" << static_cast < unsigned >(ID) << " " ;
11271132 }
11281133 }
11291134
@@ -1208,7 +1213,8 @@ void WaitcntBrackets::determineWaitForPhysReg(InstCounterType T, MCPhysReg Reg,
12081213 bool IsVGPR = Context->TRI ->isVectorRegister (*Context->MRI , Reg);
12091214 for (MCRegUnit RU : regunits (Reg))
12101215 determineWaitForScore (
1211- T, IsVGPR ? getVMemScore (RU, T) : getSGPRScore (RU, T), Wait);
1216+ T, IsVGPR ? getVMemScore (toVMEMID (RU), T) : getSGPRScore (RU, T),
1217+ Wait);
12121218 }
12131219}
12141220
@@ -2641,11 +2647,12 @@ bool SIInsertWaitcnts::shouldFlushVmCnt(MachineLoop *ML,
26412647 VgprUse.insert (RU);
26422648 // If at least one of Op's registers is in the score brackets, the
26432649 // value is likely loaded outside of the loop.
2644- if (Brackets.getVMemScore (RU, LOAD_CNT) >
2650+ unsigned ID = toVMEMID (RU);
2651+ if (Brackets.getVMemScore (ID, LOAD_CNT) >
26452652 Brackets.getScoreLB (LOAD_CNT) ||
2646- Brackets.getVMemScore (RU , SAMPLE_CNT) >
2653+ Brackets.getVMemScore (ID , SAMPLE_CNT) >
26472654 Brackets.getScoreLB (SAMPLE_CNT) ||
2648- Brackets.getVMemScore (RU , BVH_CNT) >
2655+ Brackets.getVMemScore (ID , BVH_CNT) >
26492656 Brackets.getScoreLB (BVH_CNT)) {
26502657 UsesVgprLoadedOutside = true ;
26512658 break ;
0 commit comments