1# RUN: llc -march=amdgcn -mcpu=gfx803 -verify-machineinstrs -run-pass si-insert-waitcnts -o - %s | FileCheck -check-prefixes=GCN,GFX8 %s
2# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass si-insert-waitcnts -o - %s | FileCheck -check-prefixes=GCN,GFX9 %s
3
4--- |
5
6  define amdgpu_ps void @irreducible_loop() {
7    ret void
8  }
9  define amdgpu_ps void @irreducible_loop_extended() {
10    ret void
11  }
12
13...
14---
15
16# GCN-LABEL: name: irreducible_loop{{$}}
17# GCN: S_LOAD_DWORDX4_IMM
18# GFX8: S_WAITCNT 127{{$}}
19# GFX9: S_WAITCNT 49279{{$}}
20# GCN: S_BUFFER_LOAD_DWORD_IMM
21# GFX8: S_WAITCNT 127{{$}}
22# GFX9: S_WAITCNT 49279{{$}}
23# GCN: S_CMP_GE_I32
24name:            irreducible_loop
25body:             |
26  bb.0:
27    successors: %bb.3, %bb.2
28
29    S_CBRANCH_VCCZ %bb.2, implicit $vcc
30    S_BRANCH %bb.3
31
32  bb.1:
33    successors: %bb.3, %bb.2
34
35    S_CBRANCH_VCCNZ %bb.3, implicit $vcc
36
37  bb.2:
38    successors: %bb.3
39
40    renamable $sgpr4_sgpr5_sgpr6_sgpr7 = S_LOAD_DWORDX4_IMM renamable $sgpr0_sgpr1, 0, 0, 0
41    renamable $sgpr3 = S_BUFFER_LOAD_DWORD_IMM killed renamable $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0
42
43  bb.3:
44    successors: %bb.1, %bb.4
45
46    S_CMP_GE_I32 renamable $sgpr2, renamable $sgpr3, implicit-def $scc
47    S_CBRANCH_SCC0 %bb.1, implicit killed $scc
48
49  bb.4:
50
51    S_ENDPGM 0
52
53...
54
55# GCN-LABEL: name: irreducible_loop_extended
56
57# GCN: S_LOAD_DWORDX4_IMM
58# GFX8: S_WAITCNT 127{{$}}
59# GFX9: S_WAITCNT 49279{{$}}
60# GCN: BUFFER_STORE_DWORD_OFFEN_exact
61# GFX8: S_WAITCNT 127{{$}}
62# GFX9: S_WAITCNT 49279{{$}}
63# GCN: BUFFER_STORE_DWORD_OFFEN_exact
64# GCN: S_LOAD_DWORDX4_IMM
65# GFX8: S_WAITCNT 127{{$}}
66# GFX9: S_WAITCNT 49279{{$}}
67# GCN: BUFFER_ATOMIC_ADD_OFFSET_RTN
68# GCN: S_WAITCNT 3952
69# GCN: FLAT_STORE_DWORD
70# GCN: S_ENDPGM 0
71name: irreducible_loop_extended
72
73body: |
74  bb.0:
75    successors: %bb.1, %bb.2
76    $sgpr4_sgpr5_sgpr6_sgpr7 = S_LOAD_DWORDX4_IMM renamable $sgpr2_sgpr3, 0, 0, 0
77    S_CBRANCH_VCCZ %bb.2, implicit $vcc
78
79  bb.1:
80    successors: %bb.2
81    BUFFER_STORE_DWORD_OFFEN_exact killed renamable $vgpr3, renamable $vgpr2, renamable $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, 0, 0, implicit $exec
82
83  bb.2:
84    successors: %bb.3, %bb.6
85    S_CBRANCH_VCCNZ %bb.6, implicit $vcc
86
87  bb.3:
88    successors: %bb.4, %bb.5
89    BUFFER_STORE_DWORD_OFFEN_exact killed renamable $vgpr3, killed renamable $vgpr2, killed renamable $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, 0, 0, implicit $exec
90    S_CBRANCH_VCCNZ %bb.5, implicit $vcc
91
92  bb.4:
93    successors: %bb.5
94    renamable $sgpr12_sgpr13_sgpr14_sgpr15 = S_LOAD_DWORDX4_IMM killed renamable $sgpr2_sgpr3, 64, 0, 0
95    renamable $vgpr2 = BUFFER_ATOMIC_ADD_OFFSET_RTN killed renamable $vgpr2, killed renamable $sgpr12_sgpr13_sgpr14_sgpr15, 0, 0, 1, 0, implicit $exec
96
97  bb.5:
98    successors: %bb.6
99
100  bb.6:
101    FLAT_STORE_DWORD $vgpr3_vgpr4, $vgpr2, 0, 0, 0, 0, implicit $exec, implicit $flat_scr
102    S_ENDPGM 0
103...
104