1 # RUN: llc -march=amdgcn -mcpu=gfx803 -run-pass si-insert-waitcnts %s -o - | FileCheck -check-prefix=GFX89 %s
2 # RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass si-insert-waitcnts %s -o - | FileCheck -check-prefix=GFX89 %s
5 define amdgpu_kernel void @flat_zero_waitcnt(i32 addrspace(1)* %global4,
6 <4 x i32> addrspace(1)* %global16,
12 define amdgpu_kernel void @single_fallthrough_successor_no_end_block_wait() {
16 define amdgpu_kernel void @single_branch_successor_not_next_block() {
23 # CHECK-LABEL: name: flat_zero_waitcnt
26 # CHECK: FLAT_LOAD_DWORD
27 # CHECK: FLAT_LOAD_DWORDX4
28 # Global loads will return in order so we should:
29 # s_waitcnt vmcnt(1) lgkmcnt(1)
30 # CHECK-NEXT: S_WAITCNT 369
33 # CHECK: FLAT_LOAD_DWORD
34 # GFX89: S_WAITCNT 112
35 # CHECK: FLAT_LOAD_DWORDX4
38 # CHECK: FLAT_LOAD_DWORD
39 # GFX89: S_WAITCNT 112
40 # CHECK: FLAT_LOAD_DWORDX4
42 name: flat_zero_waitcnt
47 $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2, 0, 0, 0, implicit $exec, implicit $flat_scr :: (load 4 from %ir.global4)
48 $vgpr3_vgpr4_vgpr5_vgpr6 = FLAT_LOAD_DWORDX4 $vgpr7_vgpr8, 0, 0, 0, implicit $exec, implicit $flat_scr :: (load 16 from %ir.global16)
49 $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec
54 $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2, 0, 0, 0, implicit $exec, implicit $flat_scr
55 $vgpr3_vgpr4_vgpr5_vgpr6 = FLAT_LOAD_DWORDX4 $vgpr7_vgpr8, 0, 0, 0, implicit $exec, implicit $flat_scr :: (load 16 from %ir.global16)
56 $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec
60 $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2, 0, 0, 0, implicit $exec, implicit $flat_scr :: (load 4 from %ir.flat4)
61 $vgpr3_vgpr4_vgpr5_vgpr6 = FLAT_LOAD_DWORDX4 $vgpr7_vgpr8, 0, 0, 0, implicit $exec, implicit $flat_scr :: (load 16 from %ir.flat16)
62 $vgpr0 = V_MOV_B32_e32 $vgpr1, implicit $exec
66 # There is only a single fallthrough successor block, so there's no
67 # need to wait immediately.
69 # CHECK-LABEL: name: single_fallthrough_successor_no_end_block_wait
70 # CHECK: $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2
71 # CHECK-NOT: S_WAITCNT
74 # CHECK-NEXT: V_LSHLREV_B64
75 # CHECK-NEXT: S_WAITCNT 112
76 # CHECK-NEXT: FLAT_STORE_DWORD
77 name: single_fallthrough_successor_no_end_block_wait
82 $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2, 0, 0, 0, implicit $exec, implicit $flat_scr
85 $vgpr3_vgpr4 = V_LSHLREV_B64 4, $vgpr7_vgpr8, implicit $exec
86 FLAT_STORE_DWORD $vgpr3_vgpr4, $vgpr0, 0, 0, 0, implicit $exec, implicit $flat_scr
90 # The block has a single predecessor with a single successor, but it
91 # is not the next block so it's non-obvious that the wait is not needed.
94 # CHECK-LABEL: name: single_branch_successor_not_next_block
97 # CHECK-NEXT: FLAT_STORE_DWORD
98 # CHECK-NEXT: S_ENDPGM
101 # CHECK-NEXT: V_LSHLREV_B64
102 # CHECK-NEXT: S_WAITCNT 112
103 # CHECK-NEXT: FLAT_STORE_DWORD
104 name: single_branch_successor_not_next_block
109 $vgpr0 = FLAT_LOAD_DWORD $vgpr1_vgpr2, 0, 0, 0, implicit $exec, implicit $flat_scr
113 FLAT_STORE_DWORD $vgpr8_vgpr9, $vgpr10, 0, 0, 0, implicit $exec, implicit $flat_scr
117 $vgpr3_vgpr4 = V_LSHLREV_B64 4, $vgpr7_vgpr8, implicit $exec
118 FLAT_STORE_DWORD $vgpr3_vgpr4, $vgpr0, 0, 0, 0, implicit $exec, implicit $flat_scr