Skip to content

[AMDGPU] Simplify S_WAIT_XCNT insertion. NFC. #145682

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

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed because getSgprScoresIdx asserts anyway

return SgprScores[getSgprScoresIdx(T)][GprNo - NUM_ALL_VGPRS];
}

Expand Down Expand Up @@ -866,7 +860,6 @@ void WaitcntBrackets::setScoreByInterval(RegInterval Interval,
VgprUB = std::max(VgprUB, RegNo);
VgprScores[CntTy][RegNo] = Score;
} else {
assert(isSmemCounter(CntTy));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed because getSgprScoresIdx asserts anyway

SgprUB = std::max(SgprUB, RegNo - NUM_ALL_VGPRS);
SgprScores[getSgprScoresIdx(CntTy)][RegNo - NUM_ALL_VGPRS] = Score;
}
Expand Down Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling setRegScore in a loop over an interval was silly, because setRegScore just calls setScoreByInterval with an interval of size 1.

}
}
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.
//
Expand Down
Loading