@@ -1143,6 +1143,7 @@ bool GCNHazardRecognizer::fixVcmpxPermlaneHazards(MachineInstr *MI) {
11431143bool GCNHazardRecognizer::fixVMEMtoScalarWriteHazards (MachineInstr *MI) {
11441144 if (!ST.hasVMEMtoScalarWriteHazard ())
11451145 return false ;
1146+ assert (!ST.hasExtendedWaitCounts ());
11461147
11471148 if (!SIInstrInfo::isSALU (*MI) && !SIInstrInfo::isSMRD (*MI))
11481149 return false ;
@@ -1189,6 +1190,7 @@ bool GCNHazardRecognizer::fixVMEMtoScalarWriteHazards(MachineInstr *MI) {
11891190bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards (MachineInstr *MI) {
11901191 if (!ST.hasSMEMtoVectorWriteHazard ())
11911192 return false ;
1193+ assert (!ST.hasExtendedWaitCounts ());
11921194
11931195 if (!SIInstrInfo::isVALU (*MI))
11941196 return false ;
@@ -1273,7 +1275,11 @@ bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards(MachineInstr *MI) {
12731275}
12741276
12751277bool GCNHazardRecognizer::fixVcmpxExecWARHazard (MachineInstr *MI) {
1276- if (!ST.hasVcmpxExecWARHazard () || !SIInstrInfo::isVALU (*MI))
1278+ if (!ST.hasVcmpxExecWARHazard ())
1279+ return false ;
1280+ assert (!ST.hasExtendedWaitCounts ());
1281+
1282+ if (!SIInstrInfo::isVALU (*MI))
12771283 return false ;
12781284
12791285 const SIRegisterInfo *TRI = ST.getRegisterInfo ();
@@ -1343,6 +1349,7 @@ bool GCNHazardRecognizer::fixLdsBranchVmemWARHazard(MachineInstr *MI) {
13431349 return false ;
13441350
13451351 assert (ST.hasLdsBranchVmemWARHazard ());
1352+ assert (!ST.hasExtendedWaitCounts ());
13461353
13471354 auto IsHazardInst = [](const MachineInstr &MI) {
13481355 if (SIInstrInfo::isDS (MI))
@@ -1452,6 +1459,8 @@ bool GCNHazardRecognizer::fixLdsDirectVMEMHazard(MachineInstr *MI) {
14521459 return I.readsRegister (VDSTReg, &TRI) || I.modifiesRegister (VDSTReg, &TRI);
14531460 };
14541461 bool LdsdirCanWait = ST.hasLdsWaitVMSRC ();
1462+ // TODO: On GFX12 the hazard should expire on S_WAIT_LOADCNT/SAMPLECNT/BVHCNT
1463+ // according to the type of VMEM instruction.
14551464 auto IsExpiredFn = [this , LdsdirCanWait](const MachineInstr &I, int ) {
14561465 return SIInstrInfo::isVALU (I) || SIInstrInfo::isEXP (I) ||
14571466 (I.getOpcode () == AMDGPU::S_WAITCNT && !I.getOperand (0 ).getImm ()) ||
@@ -1477,11 +1486,11 @@ bool GCNHazardRecognizer::fixLdsDirectVMEMHazard(MachineInstr *MI) {
14771486}
14781487
14791488bool GCNHazardRecognizer::fixVALUPartialForwardingHazard (MachineInstr *MI) {
1480- if (!ST.isWave64 ())
1481- return false ;
14821489 if (!ST.hasVALUPartialForwardingHazard ())
14831490 return false ;
1484- if (!SIInstrInfo::isVALU (*MI))
1491+ assert (!ST.hasExtendedWaitCounts ());
1492+
1493+ if (!ST.isWave64 () || !SIInstrInfo::isVALU (*MI))
14851494 return false ;
14861495
14871496 SmallSetVector<Register, 4 > SrcVGPRs;
@@ -1628,6 +1637,8 @@ bool GCNHazardRecognizer::fixVALUPartialForwardingHazard(MachineInstr *MI) {
16281637bool GCNHazardRecognizer::fixVALUTransUseHazard (MachineInstr *MI) {
16291638 if (!ST.hasVALUTransUseHazard ())
16301639 return false ;
1640+ assert (!ST.hasExtendedWaitCounts ());
1641+
16311642 if (!SIInstrInfo::isVALU (*MI))
16321643 return false ;
16331644
@@ -1767,6 +1778,7 @@ bool GCNHazardRecognizer::fixWMMAHazards(MachineInstr *MI) {
17671778bool GCNHazardRecognizer::fixShift64HighRegBug (MachineInstr *MI) {
17681779 if (!ST.hasShift64HighRegBug ())
17691780 return false ;
1781+ assert (!ST.hasExtendedWaitCounts ());
17701782
17711783 switch (MI->getOpcode ()) {
17721784 default :
@@ -1896,6 +1908,7 @@ int GCNHazardRecognizer::checkFPAtomicToDenormModeHazard(MachineInstr *MI) {
18961908
18971909 if (!ST.hasFPAtomicToDenormModeHazard ())
18981910 return 0 ;
1911+ assert (!ST.hasExtendedWaitCounts ());
18991912
19001913 if (MI->getOpcode () != AMDGPU::S_DENORM_MODE)
19011914 return 0 ;
@@ -2721,11 +2734,11 @@ bool GCNHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
27212734}
27222735
27232736bool GCNHazardRecognizer::fixVALUMaskWriteHazard (MachineInstr *MI) {
2724- if (!ST.isWave64 ())
2725- return false ;
27262737 if (!ST.hasVALUMaskWriteHazard ())
27272738 return false ;
2728- if (!SIInstrInfo::isSALU (*MI))
2739+ assert (!ST.hasExtendedWaitCounts ());
2740+
2741+ if (!ST.isWave64 () || !SIInstrInfo::isSALU (*MI))
27292742 return false ;
27302743
27312744 // The hazard sequence is three instructions:
0 commit comments