[llvm] [AMDGPU][SIInsertWaitCnts] Use RegUnits-based tracking (PR #162077)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 28 02:14:24 PST 2025


================
@@ -617,35 +618,29 @@ class WaitcntBrackets {
     return getScoreUB(T) - getScoreLB(T);
   }
 
-  unsigned getRegScore(int GprNo, InstCounterType T) const {
-    if (GprNo < NUM_ALL_VGPRS)
-      return VgprScores[T][GprNo];
-
-    if (GprNo < NUM_ALL_ALLOCATABLE)
-      return SgprScores[getSgprScoresIdx(T)][GprNo - NUM_ALL_VGPRS];
+  unsigned getSGPRScore(MCRegUnit RU, InstCounterType T) const {
+    auto It = SGPRs.find(RU);
+    return It != SGPRs.end() ? It->second.Scores[getSgprScoresIdx(T)] : 0;
----------------
Pierre-vh wrote:

We could, but it'd create a temporary value just to extract a zero out of it. Right now `Scores` is just 2 ints so it wouldn't be a problem, but I prefer to use the `find` pattern to be consistent with the rest, and also to avoid the temporary in case we add more to `Scores` over time and the temporary becomes big

https://github.com/llvm/llvm-project/pull/162077


More information about the llvm-commits mailing list