Skip to content

Commit 0dfc7e2

Browse files
jayfoadDavid Salinas
authored and
David Salinas
committed
[AMDGPU] Update hazard recognition for new GFX12 wait counters (llvm#78722)
In most cases the hazards no longer apply, so just assert that we are not on GFX12. Change-Id: If9fd83b679e461e17bcdfa04211807c872b092d1
1 parent 9545c24 commit 0dfc7e2

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ bool GCNHazardRecognizer::fixVcmpxPermlaneHazards(MachineInstr *MI) {
11431143
bool 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) {
11891190
bool 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

12751277
bool 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

14791488
bool 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) {
16281637
bool 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

@@ -1761,6 +1772,7 @@ bool GCNHazardRecognizer::fixWMMAHazards(MachineInstr *MI) {
17611772
bool GCNHazardRecognizer::fixShift64HighRegBug(MachineInstr *MI) {
17621773
if (!ST.hasShift64HighRegBug())
17631774
return false;
1775+
assert(!ST.hasExtendedWaitCounts());
17641776

17651777
switch (MI->getOpcode()) {
17661778
default:
@@ -1890,6 +1902,7 @@ int GCNHazardRecognizer::checkFPAtomicToDenormModeHazard(MachineInstr *MI) {
18901902

18911903
if (!ST.hasFPAtomicToDenormModeHazard())
18921904
return 0;
1905+
assert(!ST.hasExtendedWaitCounts());
18931906

18941907
if (MI->getOpcode() != AMDGPU::S_DENORM_MODE)
18951908
return 0;
@@ -2715,11 +2728,11 @@ bool GCNHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
27152728
}
27162729

27172730
bool GCNHazardRecognizer::fixVALUMaskWriteHazard(MachineInstr *MI) {
2718-
if (!ST.isWave64())
2719-
return false;
27202731
if (!ST.hasVALUMaskWriteHazard())
27212732
return false;
2722-
if (!SIInstrInfo::isSALU(*MI))
2733+
assert(!ST.hasExtendedWaitCounts());
2734+
2735+
if (!ST.isWave64() || !SIInstrInfo::isSALU(*MI))
27232736
return false;
27242737

27252738
// The hazard sequence is three instructions:

0 commit comments

Comments
 (0)