-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AMDGPU] Update hazard recognition for new GFX12 wait counters #78722
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In most cases the hazards no longer apply, so just assert that we are not on GFX12.
@llvm/pr-subscribers-backend-amdgpu Author: Jay Foad (jayfoad) ChangesIn most cases the hazards no longer apply, so just assert that we are Full diff: https://github.com/llvm/llvm-project/pull/78722.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 59ba19c71432e8..ebad40b641820e 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -1143,6 +1143,7 @@ bool GCNHazardRecognizer::fixVcmpxPermlaneHazards(MachineInstr *MI) {
bool GCNHazardRecognizer::fixVMEMtoScalarWriteHazards(MachineInstr *MI) {
if (!ST.hasVMEMtoScalarWriteHazard())
return false;
+ assert(!ST.hasExtendedWaitCounts());
if (!SIInstrInfo::isSALU(*MI) && !SIInstrInfo::isSMRD(*MI))
return false;
@@ -1189,6 +1190,7 @@ bool GCNHazardRecognizer::fixVMEMtoScalarWriteHazards(MachineInstr *MI) {
bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards(MachineInstr *MI) {
if (!ST.hasSMEMtoVectorWriteHazard())
return false;
+ assert(!ST.hasExtendedWaitCounts());
if (!SIInstrInfo::isVALU(*MI))
return false;
@@ -1273,7 +1275,11 @@ bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards(MachineInstr *MI) {
}
bool GCNHazardRecognizer::fixVcmpxExecWARHazard(MachineInstr *MI) {
- if (!ST.hasVcmpxExecWARHazard() || !SIInstrInfo::isVALU(*MI))
+ if (!ST.hasVcmpxExecWARHazard())
+ return false;
+ assert(!ST.hasExtendedWaitCounts());
+
+ if (!SIInstrInfo::isVALU(*MI))
return false;
const SIRegisterInfo *TRI = ST.getRegisterInfo();
@@ -1343,6 +1349,7 @@ bool GCNHazardRecognizer::fixLdsBranchVmemWARHazard(MachineInstr *MI) {
return false;
assert(ST.hasLdsBranchVmemWARHazard());
+ assert(!ST.hasExtendedWaitCounts());
auto IsHazardInst = [](const MachineInstr &MI) {
if (SIInstrInfo::isDS(MI))
@@ -1452,6 +1459,8 @@ bool GCNHazardRecognizer::fixLdsDirectVMEMHazard(MachineInstr *MI) {
return I.readsRegister(VDSTReg, &TRI) || I.modifiesRegister(VDSTReg, &TRI);
};
bool LdsdirCanWait = ST.hasLdsWaitVMSRC();
+ // TODO: On GFX12 the hazard should expire on S_WAIT_LOADCNT/SAMPLECNT/BVHCNT
+ // according to the type of VMEM instruction.
auto IsExpiredFn = [this, LdsdirCanWait](const MachineInstr &I, int) {
return SIInstrInfo::isVALU(I) || SIInstrInfo::isEXP(I) ||
(I.getOpcode() == AMDGPU::S_WAITCNT && !I.getOperand(0).getImm()) ||
@@ -1477,11 +1486,11 @@ bool GCNHazardRecognizer::fixLdsDirectVMEMHazard(MachineInstr *MI) {
}
bool GCNHazardRecognizer::fixVALUPartialForwardingHazard(MachineInstr *MI) {
- if (!ST.isWave64())
- return false;
if (!ST.hasVALUPartialForwardingHazard())
return false;
- if (!SIInstrInfo::isVALU(*MI))
+ assert(!ST.hasExtendedWaitCounts());
+
+ if (!ST.isWave64() || !SIInstrInfo::isVALU(*MI))
return false;
SmallSetVector<Register, 4> SrcVGPRs;
@@ -1628,6 +1637,8 @@ bool GCNHazardRecognizer::fixVALUPartialForwardingHazard(MachineInstr *MI) {
bool GCNHazardRecognizer::fixVALUTransUseHazard(MachineInstr *MI) {
if (!ST.hasVALUTransUseHazard())
return false;
+ assert(!ST.hasExtendedWaitCounts());
+
if (!SIInstrInfo::isVALU(*MI))
return false;
@@ -1767,6 +1778,7 @@ bool GCNHazardRecognizer::fixWMMAHazards(MachineInstr *MI) {
bool GCNHazardRecognizer::fixShift64HighRegBug(MachineInstr *MI) {
if (!ST.hasShift64HighRegBug())
return false;
+ assert(!ST.hasExtendedWaitCounts());
switch (MI->getOpcode()) {
default:
@@ -1896,6 +1908,7 @@ int GCNHazardRecognizer::checkFPAtomicToDenormModeHazard(MachineInstr *MI) {
if (!ST.hasFPAtomicToDenormModeHazard())
return 0;
+ assert(!ST.hasExtendedWaitCounts());
if (MI->getOpcode() != AMDGPU::S_DENORM_MODE)
return 0;
@@ -2721,11 +2734,11 @@ bool GCNHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
}
bool GCNHazardRecognizer::fixVALUMaskWriteHazard(MachineInstr *MI) {
- if (!ST.isWave64())
- return false;
if (!ST.hasVALUMaskWriteHazard())
return false;
- if (!SIInstrInfo::isSALU(*MI))
+ assert(!ST.hasExtendedWaitCounts());
+
+ if (!ST.isWave64() || !SIInstrInfo::isSALU(*MI))
return false;
// The hazard sequence is three instructions:
|
jayfoad
requested review from
rampitec,
piotrAMD,
arsenm,
mbrkusanin and
mariusz-sikora-at-amd
and removed request for
rampitec
January 19, 2024 15:08
piotrAMD
approved these changes
Jan 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
searlmc1
pushed a commit
to ROCm/llvm-project
that referenced
this pull request
Mar 28, 2024
…78722) In most cases the hazards no longer apply, so just assert that we are not on GFX12. Change-Id: If9fd83b679e461e17bcdfa04211807c872b092d1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In most cases the hazards no longer apply, so just assert that we are
not on GFX12.