[llvm] [AMDGPU][SIInsertWaitcnts][NFC] SGPRInfo: Move score selection logic closer (PR #186518)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 08:54:36 PDT 2026


================
@@ -970,14 +964,24 @@ class WaitcntBrackets {
     bool empty() const { return all_of(Scores, equal_to(0)) && !VMEMTypes; }
   };
 
-  struct SGPRInfo {
-    // Wait cnt scores for every sgpr, the DS_CNT (corresponding to LGKMcnt
-    // pre-gfx12) or KM_CNT (gfx12+ only), and X_CNT (gfx1250) are relevant.
-    // Row 0 represents the score for either DS_CNT or KM_CNT and row 1 keeps
-    // the X_CNT score.
-    std::array<unsigned, 2> Scores = {0};
+  /// Wait cnt scores for every sgpr, the DS_CNT (corresponding to LGKMcnt
+  /// pre-gfx12) or KM_CNT (gfx12+ only), and X_CNT (gfx1250) are relevant.
+  class SGPRInfo {
+    /// Either DS_CNT or KM_CNT score.
+    unsigned ScoreDsKmCnt = 0;
+    unsigned ScoreXCnt = 0;
+
+  public:
+    unsigned get(InstCounterType T) const {
+      assert((T == DS_CNT || T == KM_CNT || T == X_CNT) && "Invalid counter");
+      return T == X_CNT ? ScoreXCnt : ScoreDsKmCnt;
+    }
+    unsigned &get(InstCounterType T) {
+      assert((T == DS_CNT || T == KM_CNT || T == X_CNT) && "Invalid counter");
+      return T == X_CNT ? ScoreXCnt : ScoreDsKmCnt;
+    }
 
-    bool empty() const { return !Scores[0] && !Scores[1]; }
+    bool empty() const { return ScoreDsKmCnt == 0 && ScoreXCnt == 0; }
----------------
vporpo wrote:

It's not very clear to me what the intent of this check is. I guess it checks whether the counters are uninitialized, in which case I agree `!counter` makes more sense.

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


More information about the llvm-commits mailing list