[llvm] [AMDGPU] Simplify S_WAIT_XCNT insertion. NFC. (PR #145682)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 04:57:54 PDT 2025
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/145682
None
>From 97e014c9aff5987db4e079b3afd553d5b001e3e9 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 25 Jun 2025 12:55:40 +0100
Subject: [PATCH] [AMDGPU] Simplify S_WAIT_XCNT insertion. NFC.
---
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index f43831016952a..b223967dae900 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -302,12 +302,8 @@ class WaitcntBrackets {
}
unsigned getSgprScoresIdx(InstCounterType T) const {
- if (T == SmemAccessCounter)
- return 0;
- if (T == X_CNT)
- return 1;
-
- llvm_unreachable("Invalid SMEM counter");
+ assert(isSmemCounter(T) && "Invalid SMEM counter");
+ return T == X_CNT ? 1 : 0;
}
unsigned getScoreLB(InstCounterType T) const {
@@ -325,10 +321,8 @@ class WaitcntBrackets {
}
unsigned getRegScore(int GprNo, InstCounterType T) const {
- if (GprNo < NUM_ALL_VGPRS) {
+ if (GprNo < NUM_ALL_VGPRS)
return VgprScores[T][GprNo];
- }
- assert(isSmemCounter(T));
return SgprScores[getSgprScoresIdx(T)][GprNo - NUM_ALL_VGPRS];
}
@@ -866,7 +860,6 @@ void WaitcntBrackets::setScoreByInterval(RegInterval Interval,
VgprUB = std::max(VgprUB, RegNo);
VgprScores[CntTy][RegNo] = Score;
} else {
- assert(isSmemCounter(CntTy));
SgprUB = std::max(SgprUB, RegNo - NUM_ALL_VGPRS);
SgprScores[getSgprScoresIdx(CntTy)][RegNo - NUM_ALL_VGPRS] = Score;
}
@@ -1006,12 +999,8 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
}
}
} else if (T == X_CNT) {
- for (const MachineOperand &Op : Inst.all_uses()) {
- RegInterval Interval = getRegInterval(&Inst, MRI, TRI, Op);
- for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
- setRegScore(RegNo, T, CurrScore);
- }
- }
+ for (const MachineOperand &Op : Inst.all_uses())
+ setScoreByOperand(&Inst, TRI, MRI, Op, T, CurrScore);
} else /* LGKM_CNT || EXP_CNT || VS_CNT || NUM_INST_CNTS */ {
// Match the score to the destination registers.
//
More information about the llvm-commits
mailing list