Repository navigation
[AMDGPU][NFC] Pre-commit tests for soft waitcnt requests lost at a loop header - #244686
Conversation
|
@llvm/pr-subscribers-backend-amdgpu Author: Pablo Reble (reble) ChangesTwo cases where a soft waitcnt at a loop header loses its The checks show the current, incorrect output ( Assisted-by: Claude Opus 5.5 1 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/waitcnt-loop-carried-fence-drain.mir b/llvm/test/CodeGen/AMDGPU/waitcnt-loop-carried-fence-drain.mir
index 8268f21bb7b8e..cf6870d2f815a 100644
--- a/llvm/test/CodeGen/AMDGPU/waitcnt-loop-carried-fence-drain.mir
+++ b/llvm/test/CodeGen/AMDGPU/waitcnt-loop-carried-fence-drain.mir
@@ -52,3 +52,113 @@ body: |
bb.2:
S_ENDPGM 0
...
+
+# The soft wait at the loop header is kept on the first visit because of its
+# vmcnt (the global store in bb.0), but its lgkmcnt is simplified away because
+# no LDS operation is pending yet. The revisit through the back edge must still
+# see the original lgkmcnt(0) request for the DS write in bb.1.
+---
+name: soft_wait_partially_simplified_loop_header
+tracksRegLiveness: true
+body: |
+ ; CHECK-LABEL: name: soft_wait_partially_simplified_loop_header
+ ; CHECK: bb.0:
+ ; CHECK-NEXT: successors: %bb.1(0x80000000)
+ ; CHECK-NEXT: liveins: $vgpr1, $vgpr2, $vgpr4_vgpr5, $vgpr6, $sgpr0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: S_WAITCNT .Vmcnt_0_Expcnt_0_Lgkmcnt_0
+ ; CHECK-NEXT: GLOBAL_STORE_DWORD $vgpr4_vgpr5, $vgpr6, 0, 0, implicit $exec :: (store (s32), addrspace 1)
+ ; CHECK-NEXT: S_BRANCH %bb.1
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.1:
+ ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
+ ; CHECK-NEXT: liveins: $vgpr1, $vgpr2, $sgpr0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: S_WAITCNT .Vmcnt_0
+ ; CHECK-NEXT: S_BARRIER
+ ; CHECK-NEXT: S_WAITCNT .Lgkmcnt_0
+ ; CHECK-NEXT: renamable $vgpr3 = DS_READ_B32_gfx9 $vgpr2, 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`, addrspace 3)
+ ; CHECK-NEXT: S_WAITCNT .Lgkmcnt_0
+ ; CHECK-NEXT: DS_WRITE_B32_gfx9 $vgpr1, $vgpr3, 0, 0, implicit $exec :: (store (s32) into `ptr addrspace(3) poison`, addrspace 3)
+ ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
+ ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.1, implicit $scc
+ ; CHECK-NEXT: S_BRANCH %bb.2
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.2:
+ ; CHECK-NEXT: S_ENDPGM 0
+ bb.0:
+ successors: %bb.1
+ liveins: $vgpr1, $vgpr2, $vgpr4_vgpr5, $vgpr6, $sgpr0
+
+ GLOBAL_STORE_DWORD $vgpr4_vgpr5, $vgpr6, 0, 0, implicit $exec :: (store (s32), addrspace 1)
+ S_BRANCH %bb.1
+
+ bb.1:
+ successors: %bb.1, %bb.2
+ liveins: $vgpr1, $vgpr2, $sgpr0
+
+ S_WAITCNT_soft 112
+ S_BARRIER
+ S_WAITCNT_soft 49279
+ renamable $vgpr3 = DS_READ_B32_gfx9 $vgpr2, 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`, addrspace 3)
+ DS_WRITE_B32_gfx9 $vgpr1, $vgpr3, 0, 0, implicit $exec :: (store (s32) into `ptr addrspace(3) poison`, addrspace 3)
+ S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
+ S_CBRANCH_SCC1 %bb.1, implicit $scc
+ S_BRANCH %bb.2
+
+ bb.2:
+ S_ENDPGM 0
+...
+
+# Same, but the soft lgkmcnt(0) is merged into a preceding hard vmcnt(0).
+---
+name: soft_wait_merged_into_hard_wait_loop_header
+tracksRegLiveness: true
+body: |
+ ; CHECK-LABEL: name: soft_wait_merged_into_hard_wait_loop_header
+ ; CHECK: bb.0:
+ ; CHECK-NEXT: successors: %bb.1(0x80000000)
+ ; CHECK-NEXT: liveins: $vgpr1, $vgpr2, $sgpr0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: S_WAITCNT .Vmcnt_0_Expcnt_0_Lgkmcnt_0
+ ; CHECK-NEXT: S_BRANCH %bb.1
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.1:
+ ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
+ ; CHECK-NEXT: liveins: $vgpr1, $vgpr2, $sgpr0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: S_WAITCNT .Vmcnt_0
+ ; CHECK-NEXT: S_BARRIER
+ ; CHECK-NEXT: S_WAITCNT .Lgkmcnt_0
+ ; CHECK-NEXT: renamable $vgpr3 = DS_READ_B32_gfx9 $vgpr2, 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`, addrspace 3)
+ ; CHECK-NEXT: S_WAITCNT .Lgkmcnt_0
+ ; CHECK-NEXT: DS_WRITE_B32_gfx9 $vgpr1, $vgpr3, 0, 0, implicit $exec :: (store (s32) into `ptr addrspace(3) poison`, addrspace 3)
+ ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
+ ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.1, implicit $scc
+ ; CHECK-NEXT: S_BRANCH %bb.2
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.2:
+ ; CHECK-NEXT: S_ENDPGM 0
+ bb.0:
+ successors: %bb.1
+ liveins: $vgpr1, $vgpr2, $sgpr0
+
+ S_BRANCH %bb.1
+
+ bb.1:
+ successors: %bb.1, %bb.2
+ liveins: $vgpr1, $vgpr2, $sgpr0
+
+ S_WAITCNT 3952
+ S_WAITCNT_soft 49279
+ S_BARRIER
+ S_WAITCNT_soft 49279
+ renamable $vgpr3 = DS_READ_B32_gfx9 $vgpr2, 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`, addrspace 3)
+ DS_WRITE_B32_gfx9 $vgpr1, $vgpr3, 0, 0, implicit $exec :: (store (s32) into `ptr addrspace(3) poison`, addrspace 3)
+ S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
+ S_CBRANCH_SCC1 %bb.1, implicit $scc
+ S_BRANCH %bb.2
+
+ bb.2:
+ S_ENDPGM 0
+...
|
| S_WAITCNT_soft 49279 | ||
| S_BARRIER | ||
| S_WAITCNT_soft 49279 | ||
| renamable $vgpr3 = DS_READ_B32_gfx9 $vgpr2, 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(3) poison`, addrspace 3) |
There was a problem hiding this comment.
Can drop the poison value references
e806d4c to
7318793
Compare
krzysz00
left a comment
There was a problem hiding this comment.
Yeah, that sure is a bug, approved
…ader (NFC) Two cases where a soft waitcnt at a loop header loses its lgkmcnt(0) request: on the first visit no LDS operation is pending, so lgkmcnt is simplified away while vmcnt keeps the instruction alive (either the soft waitcnt's own vmcnt, or a preceding hard vmcnt(0) it is merged into). The DS write in the loop is then not waited for before the S_BARRIER on the next iteration. The checks show the current, incorrect output. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
35cf9d3 to
fe79300
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/4671 Here is the relevant piece of the build log for the reference |
…op header (llvm#244686) Two cases where a soft waitcnt at a loop header loses its `lgkmcnt(0)`. On the first visit to the header no LDS operation is pending yet, so the soft waitcnt's `lgkmcnt` is simplified away, while a `vmcnt` keeps the instruction alive. That `vmcnt` comes either from the soft waitcnt itself or from a preceding hard `vmcnt(0)` that it is merged into. The DS write at the end of the loop is then not waited for before the `S_BARRIER` on the next iteration. The checks show the current, incorrect output (`S_WAITCNT .Vmcnt_0` before `S_BARRIER`). Assisted-by: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Two cases where a soft waitcnt at a loop header loses its
lgkmcnt(0). On the first visit to the header no LDS operation is pending yet, so the soft waitcnt'slgkmcntis simplified away, while avmcntkeeps the instruction alive. Thatvmcntcomes either from the soft waitcnt itself or from a preceding hardvmcnt(0)that it is merged into. The DS write at the end of the loop is then not waited for before theS_BARRIERon the next iteration.The checks show the current, incorrect output (
S_WAITCNT .Vmcnt_0beforeS_BARRIER).Assisted-by: Claude Opus 5.5