[AMDGPU][SIInsertWaitcnts][NFC] Introduce Counter::advance()#193381
Open
vporpo wants to merge 1 commit intousers/vporpo/waitcnt10-3from
Open
[AMDGPU][SIInsertWaitcnts][NFC] Introduce Counter::advance()#193381vporpo wants to merge 1 commit intousers/vporpo/waitcnt10-3from
vporpo wants to merge 1 commit intousers/vporpo/waitcnt10-3from
Conversation
This patch moves the logic that advances the counter into the Counter itself.
This was referenced Apr 22, 2026
Member
|
@llvm/pr-subscribers-backend-amdgpu Author: vporpo (vporpo) ChangesThis patch moves the logic that advances the counter into the Counter itself. Previous PRs:
Full diff: https://github.com/llvm/llvm-project/pull/193381.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index cfa6ec691002a..7d9ad6bf38686 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -815,6 +815,15 @@ class WaitcntBrackets {
/// \returns true if the counter includes \p Score, i.e., it has
/// contributed to its current value, or in other words it is pending.
bool contains(unsigned Score) const { return LB < Score && Score <= UB; }
+ /// Increment the counter.
+ unsigned advance() {
+ // We are setting the value with setUB() to make sure it goes through
+ // the EXP_CNT limit enforcing code.
+ setUB(UB + 1);
+ if (UB == 0)
+ report_fatal_error("InsertWaitcnt score wraparound");
+ return UB;
+ }
};
std::array<Counter, AMDGPU::NUM_INST_CNTS> Counters;
@@ -1167,15 +1176,11 @@ void WaitcntBrackets::updateByEvent(WaitEventType E, MachineInstr &Inst) {
AMDGPU::InstCounterType T = Context->getCounterFromEvent(E);
assert(T < Context->MaxCounter);
- unsigned UB = getScoreUB(T);
- unsigned CurrScore = UB + 1;
- if (CurrScore == 0)
- report_fatal_error("InsertWaitcnt score wraparound");
- // PendingEvents and ScoreUB need to be update regardless if this event
+ unsigned CurrScore = Counters[T].advance();
+ // PendingEvents and ScoreUB need to be updated regardless if this event
// changes the score of a register or not.
// Examples including vm_cnt when buffer-store or lgkm_cnt when send-message.
PendingEvents.insert(E);
- setScoreUB(T, CurrScore);
const SIRegisterInfo &TRI = Context->TRI;
const MachineRegisterInfo &MRI = Context->MRI;
|
This file contains hidden or 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
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.
This patch moves the logic that advances the counter into the Counter itself.
Previous PRs: