1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass=si-insert-waitcnts %s -o - | FileCheck -check-prefix=GCN %s
3
4# $sgpr30_sgpr31 will hold the return address. We need a waitcnt before SI_CALL so
5# that the return address is not clobbered in the callee by the outstanding load.
6
7--- |
8  define amdgpu_kernel void @call_waw_waitcnt() #0 {
9    %1 = call i32 @func()
10    ret void
11  }
12
13  declare hidden i32 @func() #0
14
15  attributes #0 = { nounwind }
16...
17
18---
19name:            call_waw_waitcnt
20tracksRegLiveness: true
21body:             |
22  bb.0:
23    liveins: $sgpr4_sgpr5, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3
24
25    ; GCN-LABEL: name: call_waw_waitcnt
26    ; GCN: liveins: $sgpr4_sgpr5, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3
27    ; GCN: S_WAITCNT 0
28    ; GCN: $sgpr30_sgpr31 = S_LOAD_DWORDX2_IMM $sgpr4_sgpr5, 0, 0
29    ; GCN: $sgpr33 = S_MOV_B32 killed $sgpr7
30    ; GCN: $flat_scr_lo = S_ADD_U32 killed $sgpr4, $sgpr33, implicit-def $scc
31    ; GCN: $flat_scr_hi = S_ADDC_U32 killed $sgpr5, 0, implicit-def $scc, implicit killed $scc
32    ; GCN: BUNDLE implicit-def $sgpr4_sgpr5, implicit-def $sgpr4, implicit-def $sgpr5, implicit-def $scc {
33    ; GCN:   $sgpr4_sgpr5 = S_GETPC_B64
34    ; GCN:   $sgpr4 = S_ADD_U32 internal $sgpr4, target-flags(amdgpu-rel32-lo) @func + 4, implicit-def $scc
35    ; GCN:   $sgpr5 = S_ADDC_U32 internal $sgpr5, target-flags(amdgpu-rel32-hi) @func + 4, implicit-def $scc, implicit internal $scc
36    ; GCN: }
37    ; GCN: $sgpr32 = S_MOV_B32 $sgpr33
38    ; GCN: S_WAITCNT 49279
39    ; GCN: dead $sgpr30_sgpr31 = SI_CALL killed renamable $sgpr4_sgpr5, @func, csr_amdgpu_highregs, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit-def dead $vgpr0
40    ; GCN: S_ENDPGM 0
41    $sgpr30_sgpr31 = S_LOAD_DWORDX2_IMM $sgpr4_sgpr5, 0, 0
42    $sgpr33 = S_MOV_B32 killed $sgpr7
43    $flat_scr_lo = S_ADD_U32 killed $sgpr4, $sgpr33, implicit-def $scc
44    $flat_scr_hi = S_ADDC_U32 killed $sgpr5, 0, implicit-def $scc, implicit killed $scc
45    BUNDLE implicit-def $sgpr4_sgpr5, implicit-def $sgpr4, implicit-def $sgpr5, implicit-def $scc {
46      $sgpr4_sgpr5 = S_GETPC_B64
47      $sgpr4 = S_ADD_U32 internal $sgpr4, target-flags(amdgpu-rel32-lo) @func + 4, implicit-def $scc
48      $sgpr5 = S_ADDC_U32 internal $sgpr5, target-flags(amdgpu-rel32-hi) @func + 4, implicit-def $scc, implicit internal $scc
49    }
50    $sgpr32 = S_MOV_B32 $sgpr33
51    dead $sgpr30_sgpr31 = SI_CALL killed renamable $sgpr4_sgpr5, @func, csr_amdgpu_highregs, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit-def dead $vgpr0
52    S_ENDPGM 0
53...
54