[llvm] [AMDGPU][SIInsertWaitcnts] Fix underflow in expand-waitcnt-profiling when Outstanding is 0 on Pre-GFX12 (PR #202465)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 07:52:40 PDT 2026


jayfoad wrote:

> @jayfoad I went back and looked at the loops a bit. With Outstanding == 0 and Target == 0, while (Outstanding > Target) is false, so the loop never runs and no wait is emitted; appending EmitWaitcnt(Target) fixes that but duplicates Target whenever Outstanding > Target (e.g. 3/0 → 2, 1, 0, 0).

Oh, I see. This is a weird combination of two features that I had not considered. Normally `ExpandWaitcntProfiling` should not emit anything with Outstanding == 0 and Target == 0, but with `ForceEmitZeroFlag` we actually want to emit a wait for Target == 0 regardless of Outstanding.

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


More information about the llvm-commits mailing list