1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx906 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX906 %s
3 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx908 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX908 %s
4 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx1011 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX10 %s
5 ; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx1012 -verify-machineinstrs < %s | FileCheck --check-prefix=GFX10 %s
7 define i32 @v_sdot2(<2 x i16> %a, <2 x i16> %b, i32 %c) {
8 ; GFX906-LABEL: v_sdot2:
10 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
11 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
12 ; GFX906-NEXT: s_setpc_b64 s[30:31]
14 ; GFX908-LABEL: v_sdot2:
16 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
17 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
18 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
19 ; GFX908-NEXT: s_setpc_b64 s[30:31]
21 ; GFX10-LABEL: v_sdot2:
23 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
24 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
25 ; GFX10-NEXT: s_setpc_b64 s[30:31]
26 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 %c, i1 false)
30 define i32 @v_sdot2_clamp(<2 x i16> %a, <2 x i16> %b, i32 %c) {
31 ; GFX906-LABEL: v_sdot2_clamp:
33 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
34 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 clamp
35 ; GFX906-NEXT: s_setpc_b64 s[30:31]
37 ; GFX908-LABEL: v_sdot2_clamp:
39 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
40 ; GFX908-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 clamp
41 ; GFX908-NEXT: s_setpc_b64 s[30:31]
43 ; GFX10-LABEL: v_sdot2_clamp:
45 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
46 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 clamp
47 ; GFX10-NEXT: s_setpc_b64 s[30:31]
48 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 %c, i1 true)
52 define amdgpu_ps float @v_sdot2_sgpr_sgpr_sgpr(<2 x i16> inreg %a, <2 x i16> inreg %b, i32 inreg %c) {
53 ; GFX906-LABEL: v_sdot2_sgpr_sgpr_sgpr:
55 ; GFX906-NEXT: v_mov_b32_e32 v0, s1
56 ; GFX906-NEXT: v_mov_b32_e32 v1, s2
57 ; GFX906-NEXT: v_dot2_i32_i16 v0, s0, v0, v1
58 ; GFX906-NEXT: ; return to shader part epilog
60 ; GFX908-LABEL: v_sdot2_sgpr_sgpr_sgpr:
62 ; GFX908-NEXT: v_mov_b32_e32 v1, s1
63 ; GFX908-NEXT: v_mov_b32_e32 v0, s2
64 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v0, s0, v1
65 ; GFX908-NEXT: ; return to shader part epilog
67 ; GFX10-LABEL: v_sdot2_sgpr_sgpr_sgpr:
69 ; GFX10-NEXT: v_mov_b32_e32 v0, s2
70 ; GFX10-NEXT: v_dot2_i32_i16 v0, s0, s1, v0
71 ; GFX10-NEXT: ; return to shader part epilog
72 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 %c, i1 false)
73 %cast = bitcast i32 %r to float
77 define i32 @v_sdot2_inline_literal_a(<2 x i16> %b, i32 %c) {
78 ; GFX906-LABEL: v_sdot2_inline_literal_a:
80 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
81 ; GFX906-NEXT: v_dot2_i32_i16 v0, 4, v0, v1 op_sel_hi:[0,1,1]
82 ; GFX906-NEXT: s_setpc_b64 s[30:31]
84 ; GFX908-LABEL: v_sdot2_inline_literal_a:
86 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
87 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v1, 0x40004, v0
88 ; GFX908-NEXT: v_mov_b32_e32 v0, v1
89 ; GFX908-NEXT: s_setpc_b64 s[30:31]
91 ; GFX10-LABEL: v_sdot2_inline_literal_a:
93 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
94 ; GFX10-NEXT: v_dot2_i32_i16 v0, 4, v0, v1 op_sel_hi:[0,1,1]
95 ; GFX10-NEXT: s_setpc_b64 s[30:31]
96 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> <i16 4, i16 4>, <2 x i16> %b, i32 %c, i1 false)
100 define i32 @v_sdot2_inline_literal_b(<2 x i16> %a, i32 %c) {
101 ; GFX906-LABEL: v_sdot2_inline_literal_b:
103 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
104 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, 4, v1 op_sel_hi:[1,0,1]
105 ; GFX906-NEXT: s_setpc_b64 s[30:31]
107 ; GFX908-LABEL: v_sdot2_inline_literal_b:
109 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
110 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v1, 0x40004, v0
111 ; GFX908-NEXT: v_mov_b32_e32 v0, v1
112 ; GFX908-NEXT: s_setpc_b64 s[30:31]
114 ; GFX10-LABEL: v_sdot2_inline_literal_b:
116 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
117 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, 4, v1 op_sel_hi:[1,0,1]
118 ; GFX10-NEXT: s_setpc_b64 s[30:31]
119 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> <i16 4, i16 4>, i32 %c, i1 false)
123 define i32 @v_sdot2_inline_literal_a_b(<2 x i16> %a, i32 %c) {
124 ; GFX906-LABEL: v_sdot2_inline_literal_a_b:
126 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
127 ; GFX906-NEXT: v_dot2_i32_i16 v0, 8, 4, v1 op_sel_hi:[0,0,1]
128 ; GFX906-NEXT: s_setpc_b64 s[30:31]
130 ; GFX908-LABEL: v_sdot2_inline_literal_a_b:
132 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
133 ; GFX908-NEXT: v_mov_b32_e32 v0, v1
134 ; GFX908-NEXT: v_mov_b32_e32 v1, 0x40004
135 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v0, 0x80008, v1
136 ; GFX908-NEXT: s_setpc_b64 s[30:31]
138 ; GFX10-LABEL: v_sdot2_inline_literal_a_b:
140 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
141 ; GFX10-NEXT: v_dot2_i32_i16 v0, 8, 4, v1 op_sel_hi:[0,0,1]
142 ; GFX10-NEXT: s_setpc_b64 s[30:31]
143 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> <i16 8, i16 8>, <2 x i16> <i16 4, i16 4>, i32 %c, i1 false)
147 define i32 @v_sdot2_inline_literal_a_b_c() {
148 ; GFX906-LABEL: v_sdot2_inline_literal_a_b_c:
150 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
151 ; GFX906-NEXT: v_dot2_i32_i16 v0, 8, 4, 8 op_sel_hi:[0,0,1]
152 ; GFX906-NEXT: s_setpc_b64 s[30:31]
154 ; GFX908-LABEL: v_sdot2_inline_literal_a_b_c:
156 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
157 ; GFX908-NEXT: v_mov_b32_e32 v1, 0x40004
158 ; GFX908-NEXT: v_mov_b32_e32 v0, 8
159 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v0, 0x80008, v1
160 ; GFX908-NEXT: s_setpc_b64 s[30:31]
162 ; GFX10-LABEL: v_sdot2_inline_literal_a_b_c:
164 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
165 ; GFX10-NEXT: v_dot2_i32_i16 v0, 8, 4, 8 op_sel_hi:[0,0,1]
166 ; GFX10-NEXT: s_setpc_b64 s[30:31]
167 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> <i16 8, i16 8>, <2 x i16> <i16 4, i16 4>, i32 8, i1 false)
171 define i32 @v_sdot2_inline_literal_c(<2 x i16> %a, <2 x i16> %b) {
172 ; GFX906-LABEL: v_sdot2_inline_literal_c:
174 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
175 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, 7
176 ; GFX906-NEXT: s_setpc_b64 s[30:31]
178 ; GFX908-LABEL: v_sdot2_inline_literal_c:
180 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
181 ; GFX908-NEXT: v_mov_b32_e32 v2, 7
182 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
183 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
184 ; GFX908-NEXT: s_setpc_b64 s[30:31]
186 ; GFX10-LABEL: v_sdot2_inline_literal_c:
188 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
189 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, 7
190 ; GFX10-NEXT: s_setpc_b64 s[30:31]
191 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 7, i1 false)
195 define i32 @v_sdot2_fneg_a(<2 x half> %a, <2 x i16> %b, i32 %c) {
196 ; GFX906-LABEL: v_sdot2_fneg_a:
198 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
199 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 neg_lo:[1,0,0] neg_hi:[1,0,0]
200 ; GFX906-NEXT: s_setpc_b64 s[30:31]
202 ; GFX908-LABEL: v_sdot2_fneg_a:
204 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
205 ; GFX908-NEXT: v_xor_b32_e32 v0, 0x80008000, v0
206 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
207 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
208 ; GFX908-NEXT: s_setpc_b64 s[30:31]
210 ; GFX10-LABEL: v_sdot2_fneg_a:
212 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
213 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 neg_lo:[1,0,0] neg_hi:[1,0,0]
214 ; GFX10-NEXT: s_setpc_b64 s[30:31]
215 %neg.a = fneg <2 x half> %a
216 %cast.neg.a = bitcast <2 x half> %neg.a to <2 x i16>
217 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %cast.neg.a, <2 x i16> %b, i32 %c, i1 false)
221 define i32 @v_sdot2_fneg_b(<2 x i16> %a, <2 x half> %b, i32 %c) {
222 ; GFX906-LABEL: v_sdot2_fneg_b:
224 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
225 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 neg_lo:[0,1,0] neg_hi:[0,1,0]
226 ; GFX906-NEXT: s_setpc_b64 s[30:31]
228 ; GFX908-LABEL: v_sdot2_fneg_b:
230 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
231 ; GFX908-NEXT: v_xor_b32_e32 v1, 0x80008000, v1
232 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
233 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
234 ; GFX908-NEXT: s_setpc_b64 s[30:31]
236 ; GFX10-LABEL: v_sdot2_fneg_b:
238 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
239 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2 neg_lo:[0,1,0] neg_hi:[0,1,0]
240 ; GFX10-NEXT: s_setpc_b64 s[30:31]
241 %neg.b = fneg <2 x half> %b
242 %cast.neg.b = bitcast <2 x half> %neg.b to <2 x i16>
243 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %cast.neg.b, i32 %c, i1 false)
247 define i32 @v_sdot2_fnegf32_c(<2 x i16> %a, <2 x i16> %b, float %c) {
248 ; GFX906-LABEL: v_sdot2_fnegf32_c:
250 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
251 ; GFX906-NEXT: v_xor_b32_e32 v2, 0x80000000, v2
252 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
253 ; GFX906-NEXT: s_setpc_b64 s[30:31]
255 ; GFX908-LABEL: v_sdot2_fnegf32_c:
257 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
258 ; GFX908-NEXT: v_xor_b32_e32 v2, 0x80000000, v2
259 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
260 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
261 ; GFX908-NEXT: s_setpc_b64 s[30:31]
263 ; GFX10-LABEL: v_sdot2_fnegf32_c:
265 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
266 ; GFX10-NEXT: v_xor_b32_e32 v2, 0x80000000, v2
267 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
268 ; GFX10-NEXT: s_setpc_b64 s[30:31]
269 %neg.c = fneg float %c
270 %cast.neg.c = bitcast float %neg.c to i32
271 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 %cast.neg.c, i1 false)
275 define i32 @v_sdot2_fnegv2f16_c(<2 x i16> %a, <2 x i16> %b, <2 x half> %c) {
276 ; GFX906-LABEL: v_sdot2_fnegv2f16_c:
278 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
279 ; GFX906-NEXT: v_xor_b32_e32 v2, 0x80008000, v2
280 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
281 ; GFX906-NEXT: s_setpc_b64 s[30:31]
283 ; GFX908-LABEL: v_sdot2_fnegv2f16_c:
285 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
286 ; GFX908-NEXT: v_xor_b32_e32 v2, 0x80008000, v2
287 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
288 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
289 ; GFX908-NEXT: s_setpc_b64 s[30:31]
291 ; GFX10-LABEL: v_sdot2_fnegv2f16_c:
293 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
294 ; GFX10-NEXT: v_xor_b32_e32 v2, 0x80008000, v2
295 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
296 ; GFX10-NEXT: s_setpc_b64 s[30:31]
297 %neg.c = fneg <2 x half> %c
298 %cast.neg.c = bitcast <2 x half> %neg.c to i32
299 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %b, i32 %cast.neg.c, i1 false)
303 define i32 @v_sdot2_shuffle10_a(<2 x i16> %a, <2 x i16> %b, i32 %c) {
304 ; GFX906-LABEL: v_sdot2_shuffle10_a:
306 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
307 ; GFX906-NEXT: v_alignbit_b32 v0, v0, v0, 16
308 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
309 ; GFX906-NEXT: s_setpc_b64 s[30:31]
311 ; GFX908-LABEL: v_sdot2_shuffle10_a:
313 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
314 ; GFX908-NEXT: v_alignbit_b32 v0, v0, v0, 16
315 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
316 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
317 ; GFX908-NEXT: s_setpc_b64 s[30:31]
319 ; GFX10-LABEL: v_sdot2_shuffle10_a:
321 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
322 ; GFX10-NEXT: v_alignbit_b32 v0, v0, v0, 16
323 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
324 ; GFX10-NEXT: s_setpc_b64 s[30:31]
325 %shuf.a = shufflevector <2 x i16> %a, <2 x i16> undef, <2 x i32> <i32 1, i32 0>
326 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %shuf.a, <2 x i16> %b, i32 %c, i1 false)
330 define i32 @v_sdot2_shuffle10_b(<2 x i16> %a, <2 x i16> %b, i32 %c) {
331 ; GFX906-LABEL: v_sdot2_shuffle10_b:
333 ; GFX906-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
334 ; GFX906-NEXT: v_alignbit_b32 v1, v1, v1, 16
335 ; GFX906-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
336 ; GFX906-NEXT: s_setpc_b64 s[30:31]
338 ; GFX908-LABEL: v_sdot2_shuffle10_b:
340 ; GFX908-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
341 ; GFX908-NEXT: v_alignbit_b32 v1, v1, v1, 16
342 ; GFX908-NEXT: v_dot2c_i32_i16_e32 v2, v0, v1
343 ; GFX908-NEXT: v_mov_b32_e32 v0, v2
344 ; GFX908-NEXT: s_setpc_b64 s[30:31]
346 ; GFX10-LABEL: v_sdot2_shuffle10_b:
348 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
349 ; GFX10-NEXT: v_alignbit_b32 v1, v1, v1, 16
350 ; GFX10-NEXT: v_dot2_i32_i16 v0, v0, v1, v2
351 ; GFX10-NEXT: s_setpc_b64 s[30:31]
352 %shuf.b = shufflevector <2 x i16> %b, <2 x i16> undef, <2 x i32> <i32 1, i32 0>
353 %r = call i32 @llvm.amdgcn.sdot2(<2 x i16> %a, <2 x i16> %shuf.b, i32 %c, i1 false)
357 declare i32 @llvm.amdgcn.sdot2(<2 x i16>, <2 x i16>, i32, i1 immarg) #0
359 attributes #0 = { nounwind readnone speculatable }