File: vccz-corrupt-bug-workaround.mir

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (332 lines) | stat: -rw-r--r-- 9,660 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# RUN: llc -run-pass=si-insert-waitcnts -march=amdgcn -mcpu=tahiti -o - %s | FileCheck %s -check-prefixes=CHECK,SI
# RUN: llc -run-pass=si-insert-waitcnts -march=amdgcn -mcpu=gfx900 -o - %s | FileCheck %s -check-prefixes=CHECK,GFX9
# RUN: llc -run-pass=si-insert-waitcnts -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -o - %s | FileCheck %s
# RUN: llc -run-pass=si-insert-waitcnts -march=amdgcn -mcpu=gfx1100 -mattr=-wavefrontsize32,+wavefrontsize64 -o - %s | FileCheck %s
---
# CHECK-LABEL: name: vccz_corrupt_workaround
# CHECK: $vcc = V_CMP_EQ_F32
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# CHECK-NEXT: S_CBRANCH_VCCZ %bb.2, implicit killed $vcc

name: vccz_corrupt_workaround
tracksRegLiveness: true
body: |
  bb.0:
    liveins: $sgpr0_sgpr1

    $sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM killed $sgpr0_sgpr1, 11, 0
    $sgpr7 = S_MOV_B32 61440
    $sgpr6 = S_MOV_B32 -1
    $vcc = V_CMP_EQ_F32_e64 0, 0, 0, undef $sgpr2, 0, implicit $mode, implicit $exec
    S_CBRANCH_VCCZ %bb.1, implicit killed $vcc

  bb.2:
    liveins: $sgpr6, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $vgpr0 = V_MOV_B32_e32 9, implicit $exec
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 0, implicit $exec
    S_BRANCH %bb.3

  bb.1:
    liveins: $sgpr6, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $vgpr0 = V_MOV_B32_e32 100, implicit $exec
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 1, implicit $exec

  bb.3:
    liveins: $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $sgpr3 = S_MOV_B32 61440
    $sgpr2 = S_MOV_B32 -1
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, implicit $exec
    S_ENDPGM 0

...
---
# CHECK-LABEL: name: vccz_corrupt_undef_vcc
# CHECK: BUFFER_STORE_DWORD_OFFSET
# SI-NEXT: S_WAITCNT 3855
# CHECK-NEXT: $vgpr0 = V_MOV_B32_e32

name: vccz_corrupt_undef_vcc
tracksRegLiveness: true
body: |
  bb.0:
    liveins: $sgpr0_sgpr1

    $sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM killed $sgpr0_sgpr1, 11, 0
    $sgpr7 = S_MOV_B32 61440
    $sgpr6 = S_MOV_B32 -1
    S_CBRANCH_VCCZ %bb.1, implicit undef $vcc

  bb.2:
    liveins: $sgpr6, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $vgpr0 = V_MOV_B32_e32 9, implicit $exec
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 0, implicit $exec
    S_BRANCH %bb.3

  bb.1:
    liveins: $sgpr6, $sgpr7, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $vgpr0 = V_MOV_B32_e32 100, implicit $exec
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec
    $vgpr0 = V_MOV_B32_e32 1, implicit $exec

  bb.3:
    liveins: $vgpr0, $sgpr0_sgpr1_sgpr2_sgpr3:0x00000003

    $sgpr3 = S_MOV_B32 61440
    $sgpr2 = S_MOV_B32 -1
    BUFFER_STORE_DWORD_OFFSET killed $vgpr0, killed $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, implicit $exec
    S_ENDPGM 0

...
---
# Test that after reloading vcc spilled to a vgpr, we insert any necessary
# instructions to fix vccz.

# CHECK-LABEL: name: reload_vcc_from_vgpr
# CHECK: $vcc_lo = V_READLANE_B32 $vgpr0, 8, implicit-def $vcc
# CHECK: $vcc_hi = V_READLANE_B32 $vgpr0, 9
# SI:    $vcc = S_MOV_B64 $vcc
# GFX9:  $vcc = S_MOV_B64 $vcc
# CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc

name: reload_vcc_from_vgpr
body: |
  bb.0:
    $vcc_lo = V_READLANE_B32 $vgpr0, 8, implicit-def $vcc
    $vcc_hi = V_READLANE_B32 $vgpr0, 9
    S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
  bb.1:

...
---
# Test that after reloading vcc spilled to memory, we insert any necessary
# instructions to fix vccz.

# CHECK-LABEL: name: reload_vcc_from_mem
# CHECK: $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec
# CHECK: $vcc_lo = V_READFIRSTLANE_B32 killed $vgpr0, implicit $exec, implicit-def $vcc
# CHECK: $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec
# CHECK: $vcc_hi = V_READFIRSTLANE_B32 killed $vgpr0, implicit $exec, implicit-def $vcc
# SI:    $vcc = S_MOV_B64 $vcc
# GFX9:  $vcc = S_MOV_B64 $vcc
# CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc

name: reload_vcc_from_mem
body: |
  bb.0:
    $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 4, 0, 0, implicit $exec
    $vcc_lo = V_READFIRSTLANE_B32 killed $vgpr0, implicit $exec, implicit-def $vcc
    $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4, 8, 0, 0, implicit $exec
    $vcc_hi = V_READFIRSTLANE_B32 killed $vgpr0, implicit $exec, implicit-def $vcc
    S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
  bb.1:

...
---
# Test that after inline asm that defines vcc_lo, we insert any necessary
# instructions to fix vccz.

# CHECK-LABEL: name: inlineasm_def_vcc_lo
# CHECK: INLINEASM &"; def vcc_lo", 1 /* sideeffect attdialect */, 10 /* regdef */, implicit-def $vcc_lo
# SI:    $vcc = S_MOV_B64 $vcc
# GFX9:  $vcc = S_MOV_B64 $vcc
# CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc

name: inlineasm_def_vcc_lo
body: |
  bb.0:
    INLINEASM &"; def vcc_lo", 1, 10, implicit-def $vcc_lo
    S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
  bb.1:

...
---
# Test that after inline asm that defines vcc, no unnecessary instructions are
# inserted to fix vccz.

# CHECK-LABEL: name: inlineasm_def_vcc
# CHECK: INLINEASM &"; def vcc", 1 /* sideeffect attdialect */, 10 /* regdef */, implicit-def $vcc
# CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc

name: inlineasm_def_vcc
body: |
  bb.0:
    INLINEASM &"; def vcc", 1, 10, implicit-def $vcc
    S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
  bb.1:

...
---
# Test vcc definition in a previous basic block.

# CHECK-LABEL: name: vcc_def_pred
# CHECK: bb.1:
# SI:  $vcc = S_MOV_B64 $vcc
# GFX9:  $vcc = S_MOV_B64 $vcc
# CHECK: S_CBRANCH_VCCZ %bb.2, implicit $vcc

name: vcc_def_pred
body: |
  bb.0:
    $vcc = S_MOV_B64 0
  bb.1:
    S_CBRANCH_VCCZ %bb.2, implicit $vcc
  bb.2:

...

# Test various ways that the live range of vccz can overlap with the live range
# of an outstanding smem load.

---
# CHECK-LABEL: name: load_wait_def_use
# SI: S_WAITCNT 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: load_wait_def_use
body: |
  bb.0:
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    S_WAITCNT 127
    $vcc = S_MOV_B64 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: load_wait_nop_def_use
# SI: S_WAITCNT 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: S_NOP 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: load_wait_nop_def_use
body: |
  bb.0:
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    S_WAITCNT 127
    S_NOP 0
    $vcc = S_MOV_B64 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: load_def_wait_use
# SI: S_WAITCNT 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: load_def_wait_use
body: |
  bb.0:
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    $vcc = S_MOV_B64 0
    S_WAITCNT 127
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

# CHECK-LABEL: name: load_def_wait_nop_use
# SI: S_WAITCNT 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: S_NOP 0
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: load_def_wait_nop_use
body: |
  bb.0:
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    $vcc = S_MOV_B64 0
    S_WAITCNT 127
    S_NOP 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: load_def_use
# SI: S_WAITCNT 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: load_def_use
body: |
  bb.0:
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    $vcc = S_MOV_B64 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: def_load_wait_use
# SI: S_WAITCNT 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: def_load_wait_use
body: |
  bb.0:
    $vcc = S_MOV_B64 0
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    S_WAITCNT 127
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: def_load_wait_nop_use
# SI: S_WAITCNT 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: S_NOP 0
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: def_load_wait_nop_use
body: |
  bb.0:
    $vcc = S_MOV_B64 0
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    S_WAITCNT 127
    S_NOP 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...

---
# CHECK-LABEL: name: def_load_use
# SI: S_WAITCNT 0
# SI-NEXT: $vcc = S_MOV_B64 0
# SI-NEXT: $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
# SI-NEXT: S_WAITCNT 127
# SI-NEXT: $vcc = S_MOV_B64 $vcc
# SI-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
name: def_load_use
body: |
  bb.0:
    $vcc = S_MOV_B64 0
    $sgpr0 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 0, 0
    S_CBRANCH_VCCZ %bb.1, implicit $vcc
  bb.1:
...