llvm.amdgcn.writelane.ll
12 KB
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
333
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx700 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX7 %s
; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx803 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX8 %s
; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX10 %s
define amdgpu_ps float @test_writelane_s_s_s(i32 inreg %data, i32 inreg %lane, i32 inreg %vdst.in) #0 {
; GFX7-LABEL: test_writelane_s_s_s:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_mov_b32_e32 v0, s4
; GFX7-NEXT: s_mov_b32 m0, s3
; GFX7-NEXT: v_writelane_b32 v0, s2, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_s_s:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_mov_b32_e32 v0, s4
; GFX8-NEXT: s_mov_b32 m0, s3
; GFX8-NEXT: v_writelane_b32 v0, s2, m0
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mov_b32_e32 v0, s4
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v0, s2, s3
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
define amdgpu_ps float @test_writelane_s_s_imm(i32 inreg %data, i32 inreg %lane) #0 {
; GFX7-LABEL: test_writelane_s_s_imm:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_mov_b32_e32 v0, 42
; GFX7-NEXT: s_mov_b32 m0, s3
; GFX7-NEXT: v_writelane_b32 v0, s2, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_s_imm:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_mov_b32_e32 v0, 42
; GFX8-NEXT: s_mov_b32 m0, s3
; GFX8-NEXT: v_writelane_b32 v0, s2, m0
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_s_imm:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mov_b32_e32 v0, 42
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v0, s2, s3
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 %lane, i32 42)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; data is not inline imm
define amdgpu_ps float @test_writelane_k_s_v(i32 inreg %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_k_s_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: s_movk_i32 s0, 0x3e7
; GFX7-NEXT: s_mov_b32 m0, s2
; GFX7-NEXT: v_writelane_b32 v0, s0, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_k_s_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: s_movk_i32 s0, 0x3e7
; GFX8-NEXT: s_mov_b32 m0, s2
; GFX8-NEXT: v_writelane_b32 v0, s0, m0
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_k_s_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: s_movk_i32 s0, 0x3e7
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v0, s0, s2
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 999, i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; Data is inline imm
define amdgpu_ps float @test_writelane_imm_s_v(i32 inreg %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_imm_s_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_writelane_b32 v0, 42, s2
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_imm_s_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_writelane_b32 v0, 42, s2
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_imm_s_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_writelane_b32 v0, 42, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 42, i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; Data is subtarget dependent inline imm
define amdgpu_ps float @test_writelane_imminv2pi_s_v(i32 inreg %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_imminv2pi_s_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: s_mov_b32 s0, 0x3e22f983
; GFX7-NEXT: s_mov_b32 m0, s2
; GFX7-NEXT: v_writelane_b32 v0, s0, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_imminv2pi_s_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_writelane_b32 v0, 0.15915494, s2
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_imminv2pi_s_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_writelane_b32 v0, 0.15915494, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 bitcast (float 0x3FC45F3060000000 to i32), i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; Lane is inline imm
define amdgpu_ps float @test_writelane_s_imm_v(i32 inreg %data, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_s_imm_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_writelane_b32 v0, s2, 23
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_imm_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_writelane_b32 v0, s2, 23
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_imm_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_writelane_b32 v0, s2, 23
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 23, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; Lane index is larger than the wavesize
define amdgpu_ps float @test_writelane_s_k0_v(i32 inreg %data, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_s_k0_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_writelane_b32 v0, s2, 3
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_k0_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_writelane_b32 v0, s2, 3
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_k0_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: s_movk_i32 s0, 0x43
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v0, s2, s0
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 67, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; Lane index is larger than the wavesize for wave32
define amdgpu_ps float @test_writelane_s_k1_v(i32 inreg %data, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_s_k1_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_writelane_b32 v0, s2, 32
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_k1_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_writelane_b32 v0, s2, 32
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_k1_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_writelane_b32 v0, s2, 32
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 32, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
define amdgpu_ps float @test_writelane_v_v_v(i32 %data, i32 %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_v_v_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_readfirstlane_b32 s1, v1
; GFX7-NEXT: v_readfirstlane_b32 s0, v0
; GFX7-NEXT: s_mov_b32 m0, s1
; GFX7-NEXT: v_writelane_b32 v2, s0, m0
; GFX7-NEXT: v_mov_b32_e32 v0, v2
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_v_v_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_readfirstlane_b32 s1, v1
; GFX8-NEXT: v_readfirstlane_b32 s0, v0
; GFX8-NEXT: s_mov_b32 m0, s1
; GFX8-NEXT: v_writelane_b32 v2, s0, m0
; GFX8-NEXT: v_mov_b32_e32 v0, v2
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_v_v_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_readfirstlane_b32 s0, v0
; GFX10-NEXT: v_readfirstlane_b32 s1, v1
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v2, s0, s1
; GFX10-NEXT: v_mov_b32_e32 v0, v2
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
define amdgpu_ps float @test_writelane_v_s_v(i32 %data, i32 inreg %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_v_s_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: v_readfirstlane_b32 s0, v0
; GFX7-NEXT: s_mov_b32 m0, s2
; GFX7-NEXT: v_writelane_b32 v1, s0, m0
; GFX7-NEXT: v_mov_b32_e32 v0, v1
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_v_s_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: v_readfirstlane_b32 s0, v0
; GFX8-NEXT: s_mov_b32 m0, s2
; GFX8-NEXT: v_writelane_b32 v1, s0, m0
; GFX8-NEXT: v_mov_b32_e32 v0, v1
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_v_s_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_readfirstlane_b32 s0, v0
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_writelane_b32 v1, s0, s2
; GFX10-NEXT: v_mov_b32_e32 v0, v1
; GFX10-NEXT: ; return to shader part epilog
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 inreg %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
; FIXME: This could theoretically use m0 directly as the data source,
; and another SGPR as the lane selector and avoid register swap.
define amdgpu_ps float @test_writelane_m0_s_v(i32 inreg %lane, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_m0_s_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: ;;#ASMSTART
; GFX7-NEXT: s_mov_b32 m0, -1
; GFX7-NEXT: ;;#ASMEND
; GFX7-NEXT: s_mov_b32 s0, m0
; GFX7-NEXT: s_mov_b32 m0, s2
; GFX7-NEXT: v_writelane_b32 v0, s0, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_m0_s_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: ;;#ASMSTART
; GFX8-NEXT: s_mov_b32 m0, -1
; GFX8-NEXT: ;;#ASMEND
; GFX8-NEXT: s_mov_b32 s0, m0
; GFX8-NEXT: s_mov_b32 m0, s2
; GFX8-NEXT: v_writelane_b32 v0, s0, m0
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_m0_s_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: ;;#ASMSTART
; GFX10-NEXT: s_mov_b32 m0, -1
; GFX10-NEXT: ;;#ASMEND
; GFX10-NEXT: v_writelane_b32 v0, m0, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%m0 = call i32 asm "s_mov_b32 m0, -1", "={m0}"()
%writelane = call i32 @llvm.amdgcn.writelane(i32 %m0, i32 %lane, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
define amdgpu_ps float @test_writelane_s_m0_v(i32 inreg %data, i32 %vdst.in) #0 {
; GFX7-LABEL: test_writelane_s_m0_v:
; GFX7: ; %bb.0:
; GFX7-NEXT: ;;#ASMSTART
; GFX7-NEXT: s_mov_b32 m0, -1
; GFX7-NEXT: ;;#ASMEND
; GFX7-NEXT: v_writelane_b32 v0, s2, m0
; GFX7-NEXT: ; return to shader part epilog
;
; GFX8-LABEL: test_writelane_s_m0_v:
; GFX8: ; %bb.0:
; GFX8-NEXT: ;;#ASMSTART
; GFX8-NEXT: s_mov_b32 m0, -1
; GFX8-NEXT: ;;#ASMEND
; GFX8-NEXT: v_writelane_b32 v0, s2, m0
; GFX8-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: test_writelane_s_m0_v:
; GFX10: ; %bb.0:
; GFX10-NEXT: ;;#ASMSTART
; GFX10-NEXT: s_mov_b32 m0, -1
; GFX10-NEXT: ;;#ASMEND
; GFX10-NEXT: v_writelane_b32 v0, s2, m0
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%m0 = call i32 asm "s_mov_b32 m0, -1", "={m0}"()
%writelane = call i32 @llvm.amdgcn.writelane(i32 %data, i32 %m0, i32 %vdst.in)
%writelane.cast = bitcast i32 %writelane to float
ret float %writelane.cast
}
declare i32 @llvm.amdgcn.writelane(i32, i32, i32) #1
declare i32 @llvm.amdgcn.workitem.id.x() #2
attributes #0 = { nounwind }
attributes #1 = { convergent nounwind readnone willreturn }
attributes #2 = { nounwind readnone speculatable willreturn }