358 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -mtriple=amdgcn -mcpu=gfx90a -run-pass si-insert-waitcnts -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s3 4--- |5 define amdgpu_kernel void @flat_zero_waitcnt(ptr addrspace(1) %global4,6 ptr addrspace(1) %global16,7 ptr %flat4,8 ptr %flat16) {9 ret void10 }11 12 define amdgpu_kernel void @single_fallthrough_successor_no_end_block_wait() {13 ret void14 }15 16 define amdgpu_kernel void @single_branch_successor_not_next_block() {17 ret void18 }19 20 define amdgpu_kernel void @preexisting_waitcnt() {21 ret void22 }23 24 define amdgpu_kernel void @bundle_no_waitcnt() {25 ret void26 }27 28 define amdgpu_kernel void @preexisting_waitcnt_in_bundle() {29 ret void30 }31 32 define amdgpu_kernel void @insert_in_bundle() {33 ret void34 }35 36 define amdgpu_kernel void @exit_bundle() {37 ret void38 }39 40 define amdgpu_kernel void @cross_bundle() {41 ret void42 }43 44 define amdgpu_kernel void @high_register_collision() {45 ret void46 }47 48...49---50 51 52# Global loads will return in order so we should:53# s_waitcnt vmcnt(1)54 55# s_waitcnt vmcnt(0)56 57# s_waitcnt vmcnt(0)58 59name: flat_zero_waitcnt60 61body: |62 ; GCN-LABEL: name: flat_zero_waitcnt63 ; GCN: bb.0:64 ; GCN-NEXT: successors: %bb.1(0x80000000)65 ; GCN-NEXT: {{ $}}66 ; GCN-NEXT: S_WAITCNT 067 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.global4, addrspace 1)68 ; GCN-NEXT: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16, addrspace 1)69 ; GCN-NEXT: S_WAITCNT 395370 ; GCN-NEXT: $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec71 ; GCN-NEXT: S_BRANCH %bb.172 ; GCN-NEXT: {{ $}}73 ; GCN-NEXT: bb.1:74 ; GCN-NEXT: successors: %bb.2(0x80000000)75 ; GCN-NEXT: {{ $}}76 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr77 ; GCN-NEXT: S_WAITCNT 395278 ; GCN-NEXT: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16, addrspace 1)79 ; GCN-NEXT: $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec80 ; GCN-NEXT: S_BRANCH %bb.281 ; GCN-NEXT: {{ $}}82 ; GCN-NEXT: bb.2:83 ; GCN-NEXT: S_WAITCNT 4927984 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.flat4)85 ; GCN-NEXT: S_WAITCNT 395286 ; GCN-NEXT: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.flat16)87 ; GCN-NEXT: $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec88 ; GCN-NEXT: S_ENDPGM 089 bb.0:90 successors: %bb.191 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.global4)92 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16)93 $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec94 S_BRANCH %bb.195 96 bb.1:97 successors: %bb.298 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr99 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16)100 $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec101 S_BRANCH %bb.2102 103 bb.2:104 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.flat4)105 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.flat16)106 $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec107 S_ENDPGM 0108...109---110# There is only a single fallthrough successor block, so there's no111# need to wait immediately.112 113 114name: single_fallthrough_successor_no_end_block_wait115 116body: |117 ; GCN-LABEL: name: single_fallthrough_successor_no_end_block_wait118 ; GCN: bb.0:119 ; GCN-NEXT: successors: %bb.1(0x80000000)120 ; GCN-NEXT: {{ $}}121 ; GCN-NEXT: S_WAITCNT 0122 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr123 ; GCN-NEXT: {{ $}}124 ; GCN-NEXT: bb.1:125 ; GCN-NEXT: $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec126 ; GCN-NEXT: S_WAITCNT 112127 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr128 ; GCN-NEXT: S_ENDPGM 0129 bb.0:130 successors: %bb.1131 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr132 133 bb.1:134 $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec135 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr136 S_ENDPGM 0137...138---139# The block has a single predecessor with a single successor, but it140# is not the next block so it's non-obvious that the wait is not needed.141 142 143 144 145name: single_branch_successor_not_next_block146 147body: |148 ; GCN-LABEL: name: single_branch_successor_not_next_block149 ; GCN: bb.0:150 ; GCN-NEXT: successors: %bb.2(0x80000000)151 ; GCN-NEXT: {{ $}}152 ; GCN-NEXT: S_WAITCNT 0153 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr154 ; GCN-NEXT: S_BRANCH %bb.2155 ; GCN-NEXT: {{ $}}156 ; GCN-NEXT: bb.1:157 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr8_vgpr9, $agpr10, 0, 0, implicit $exec, implicit $flat_scr158 ; GCN-NEXT: S_ENDPGM 0159 ; GCN-NEXT: {{ $}}160 ; GCN-NEXT: bb.2:161 ; GCN-NEXT: $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec162 ; GCN-NEXT: S_WAITCNT 112163 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr164 ; GCN-NEXT: S_ENDPGM 0165 bb.0:166 successors: %bb.2167 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr168 S_BRANCH %bb.2169 170 bb.1:171 FLAT_STORE_DWORD $vgpr8_vgpr9, $agpr10, 0, 0, implicit $exec, implicit $flat_scr172 S_ENDPGM 0173 174 bb.2:175 $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec176 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr177 S_ENDPGM 0178...179 180# GCN-LABEL: name: preexisting_waitcnt{{$}}181# GCN: FLAT_LOAD_DWORD182# GCN-NEXT: S_WAITCNT 0183# GCN-NOT: S_WAITCNT184name: preexisting_waitcnt185tracksRegLiveness: true186machineFunctionInfo:187 isEntryFunction: true188body: |189 bb.0:190 liveins: $vgpr1_vgpr2191 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr192 S_WAITCNT 0193 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr194 195...196 197---198 199name: bundle_no_waitcnt200tracksRegLiveness: true201machineFunctionInfo:202 isEntryFunction: true203body: |204 bb.0:205 liveins: $vgpr1_vgpr2206 ; GCN-LABEL: name: bundle_no_waitcnt207 ; GCN: liveins: $vgpr1_vgpr2208 ; GCN-NEXT: {{ $}}209 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr210 ; GCN-NEXT: BUNDLE {211 ; GCN-NEXT: S_NOP 0212 ; GCN-NEXT: S_NOP 0213 ; GCN-NEXT: }214 ; GCN-NEXT: S_WAITCNT 112215 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr216 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr217 BUNDLE {218 S_NOP 0219 S_NOP 0220 }221 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr222 223...224 225---226 227# See the waitcnt inside the bundle and don't insert an extra228name: preexisting_waitcnt_in_bundle229tracksRegLiveness: true230machineFunctionInfo:231 isEntryFunction: true232body: |233 bb.0:234 liveins: $vgpr1_vgpr2235 ; GCN-LABEL: name: preexisting_waitcnt_in_bundle236 ; GCN: liveins: $vgpr1_vgpr2237 ; GCN-NEXT: {{ $}}238 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr239 ; GCN-NEXT: BUNDLE {240 ; GCN-NEXT: S_NOP 0241 ; GCN-NEXT: S_WAITCNT 0242 ; GCN-NEXT: }243 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr244 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr245 BUNDLE {246 S_NOP 0247 S_WAITCNT 0248 }249 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr250 251...252 253---254 255# Def and use inside bundle256 257name: insert_in_bundle258tracksRegLiveness: true259machineFunctionInfo:260 isEntryFunction: true261body: |262 bb.0:263 liveins: $vgpr1_vgpr2264 ; GCN-LABEL: name: insert_in_bundle265 ; GCN: liveins: $vgpr1_vgpr2266 ; GCN-NEXT: {{ $}}267 ; GCN-NEXT: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {268 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr269 ; GCN-NEXT: S_WAITCNT 112270 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr2_vgpr3, internal $agpr0, 0, 0, implicit $exec, implicit $flat_scr271 ; GCN-NEXT: }272 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {273 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr274 FLAT_STORE_DWORD $vgpr2_vgpr3, internal $agpr0, 0, 0, implicit $exec, implicit $flat_scr275 }276...277 278---279 280# Def is last instruction in bundle, use is outside bundle281 282 283name: exit_bundle284tracksRegLiveness: true285machineFunctionInfo:286 isEntryFunction: true287body: |288 bb.0:289 liveins: $vgpr1_vgpr2290 ; GCN-LABEL: name: exit_bundle291 ; GCN: liveins: $vgpr1_vgpr2292 ; GCN-NEXT: {{ $}}293 ; GCN-NEXT: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {294 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr295 ; GCN-NEXT: }296 ; GCN-NEXT: S_WAITCNT 112297 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr298 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {299 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr300 }301 302 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr303 304...305 306---307 308# Def is in bundle, use is in another bundle309 310 311name: cross_bundle312tracksRegLiveness: true313machineFunctionInfo:314 isEntryFunction: true315body: |316 bb.0:317 liveins: $vgpr1_vgpr2318 ; GCN-LABEL: name: cross_bundle319 ; GCN: liveins: $vgpr1_vgpr2320 ; GCN-NEXT: {{ $}}321 ; GCN-NEXT: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {322 ; GCN-NEXT: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr323 ; GCN-NEXT: }324 ; GCN-NEXT: BUNDLE implicit $agpr0, implicit $vgpr2_vgpr3 {325 ; GCN-NEXT: S_WAITCNT 112326 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr327 ; GCN-NEXT: }328 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {329 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr330 }331 BUNDLE implicit $agpr0, implicit $vgpr2_vgpr3 {332 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr333 }334...335 336---337# agpr should be disjoint and tracked separately from vgpr338 339name: high_register_collision340 341body: |342 bb.0:343 ; GCN-LABEL: name: high_register_collision344 ; GCN: S_WAITCNT 0345 ; GCN-NEXT: $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec346 ; GCN-NEXT: $vgpr226 = FLAT_LOAD_DWORD $vgpr6_vgpr7, 0, 0, implicit $exec, implicit $flat_scr347 ; GCN-NEXT: $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec348 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr1, 0, 0, implicit $exec, implicit $flat_scr349 ; GCN-NEXT: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr350 ; GCN-NEXT: S_ENDPGM 0351 $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec352 $vgpr226 = FLAT_LOAD_DWORD $vgpr6_vgpr7, 0, 0, implicit $exec, implicit $flat_scr353 $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec354 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr1, 0, 0, implicit $exec, implicit $flat_scr355 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr356 S_ENDPGM 0357...358