[llvm] [AMDGPU] Add DS loop waitcnt optimization for GFX12+ (PR #172728)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 17 14:55:17 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 6b0bcfc6b..4de55653e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -2702,8 +2702,9 @@ bool SIInsertWaitcnts::insertWaitcntInBlock(MachineFunction &MF,
}
// Return flags indicating which counters should be flushed in the preheader.
-PreheaderFlushFlags SIInsertWaitcnts::isPreheaderToFlush(
- MachineBasicBlock &MBB, const WaitcntBrackets &ScoreBrackets) {
+PreheaderFlushFlags
+SIInsertWaitcnts::isPreheaderToFlush(MachineBasicBlock &MBB,
+ const WaitcntBrackets &ScoreBrackets) {
auto [Iterator, IsInserted] =
PreheadersToFlush.try_emplace(&MBB, PreheaderFlushFlags());
if (!IsInserted)
@@ -2830,14 +2831,14 @@ SIInsertWaitcnts::getPreheaderFlushFlags(MachineLoop *ML,
// Check if loaded outside the loop via DS (not VMEM/FLAT)
// Only consider it a DS load if there's no pending VMEM load for
// this register, since FLAT can set both counters.
- bool HasPendingVMEM = Brackets.getVMemScore(ID, LOAD_CNT) >
- Brackets.getScoreLB(LOAD_CNT) ||
- Brackets.getVMemScore(ID, SAMPLE_CNT) >
- Brackets.getScoreLB(SAMPLE_CNT) ||
- Brackets.getVMemScore(ID, BVH_CNT) >
- Brackets.getScoreLB(BVH_CNT);
- if (!HasPendingVMEM && Brackets.getVMemScore(ID, DS_CNT) >
- Brackets.getScoreLB(DS_CNT)) {
+ bool HasPendingVMEM =
+ Brackets.getVMemScore(ID, LOAD_CNT) >
+ Brackets.getScoreLB(LOAD_CNT) ||
+ Brackets.getVMemScore(ID, SAMPLE_CNT) >
+ Brackets.getScoreLB(SAMPLE_CNT) ||
+ Brackets.getVMemScore(ID, BVH_CNT) > Brackets.getScoreLB(BVH_CNT);
+ if (!HasPendingVMEM &&
+ Brackets.getVMemScore(ID, DS_CNT) > Brackets.getScoreLB(DS_CNT)) {
UsesVgprLoadedOutsideDS = true;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/172728
More information about the llvm-commits
mailing list