[PATCH] D136677: [AMDGPU] Small cleanups in wait counter code

Stephen Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 04:05:04 PDT 2022


stepthomas added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp:1223
   if (FlushVmCnt) {
-    unsigned UB = ScoreBrackets.getScoreUB(VM_CNT);
-    unsigned LB = ScoreBrackets.getScoreLB(VM_CNT);
-    if (UB - LB != 0)
+    if (ScoreBrackets.getScoreRange(VM_CNT) != 0)
       Wait.VmCnt = 0;
----------------
scott.linder wrote:
> I would suggest also adding a `hasPendingEvent(InstCounterType T) const` overload to use here, i.e.
> 
> ```
>   bool hasPendingEvent(InstCounterType T) const {
>     bool HasPending = PendingEvents & WaitEventMaskForInst[T];
>     assert(HasPending == getScoreUB(T) > getScoreLB(T));
>     return HasPending;
>   }
> ```
I'll add this suggestion, including renaming the void parameter overloading, although I'll also change the return type to `unsigned` (and the void parameter overloading simply returns `PendingEvents`) because then I can use the new overloading in `hasMixedPendingEvents()` immediately blow this code (so getting an extra assertion check). It makes the assertion 
```
  assert((HasPending != 0) == (getScoreRange(T) != 0))
```
which is ugly, but still worth it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136677/new/

https://reviews.llvm.org/D136677



More information about the llvm-commits mailing list