[AMDGPU] Make v8i16/v8f16 legal
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / GlobalISel / inst-select-trunc.mir
blob9e4d9edd9e52cdf3b83dbaeec0eeb392e38871ef
1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -run-pass=instruction-select -verify-machineinstrs  %s -o - | FileCheck %s -check-prefixes=GCN
4 ---
6 name: trunc_sgpr_s32_to_s1
7 legalized:       true
8 regBankSelected: true
10 body: |
11   bb.0:
12     liveins: $sgpr0
13     ; GCN-LABEL: name: trunc_sgpr_s32_to_s1
14     ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
15     ; GCN: S_ENDPGM 0, implicit [[COPY]]
16     %0:sgpr(s32) = COPY $sgpr0
17     %1:sgpr(s1) = G_TRUNC %0
18     S_ENDPGM 0, implicit %1
19 ...
20 ---
22 name: trunc_sgpr_s32_to_s16
23 legalized:       true
24 regBankSelected: true
26 body: |
27   bb.0:
28     liveins: $sgpr0
29     ; GCN-LABEL: name: trunc_sgpr_s32_to_s16
30     ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
31     ; GCN: S_ENDPGM 0, implicit [[COPY]]
32     %0:sgpr(s32) = COPY $sgpr0
33     %1:sgpr(s16) = G_TRUNC %0
34     S_ENDPGM 0, implicit %1
35 ...
36 ---
38 name: trunc_sgpr_s64_to_s32
39 legalized:       true
40 regBankSelected: true
42 body: |
43   bb.0:
44     liveins: $sgpr0_sgpr1
45     ; GCN-LABEL: name: trunc_sgpr_s64_to_s32
46     ; GCN: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
47     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
48     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
49     %0:sgpr(s64) = COPY $sgpr0_sgpr1
50     %1:sgpr(s32) = G_TRUNC %0
51     S_ENDPGM 0, implicit %1
52 ...
53 ---
55 name: trunc_sgpr_s64_to_s16
56 legalized:       true
57 regBankSelected: true
59 body: |
60   bb.0:
61     liveins: $sgpr0_sgpr1
62     ; GCN-LABEL: name: trunc_sgpr_s64_to_s16
63     ; GCN: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
64     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
65     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
66     %0:sgpr(s64) = COPY $sgpr0_sgpr1
67     %1:sgpr(s16) = G_TRUNC %0
68     S_ENDPGM 0, implicit %1
69 ...
70 ---
72 name: trunc_sgpr_s64_to_s1
73 legalized:       true
74 regBankSelected: true
76 body: |
77   bb.0:
78     liveins: $sgpr0_sgpr1
79     ; GCN-LABEL: name: trunc_sgpr_s64_to_s1
80     ; GCN: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr0_sgpr1
81     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
82     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
83     %0:sgpr(s64) = COPY $sgpr0_sgpr1
84     %1:sgpr(s1) = G_TRUNC %0
85     S_ENDPGM 0, implicit %1
86 ...
87 ---
89 name: trunc_sgpr_s96_to_s16
90 legalized:       true
91 regBankSelected: true
93 body: |
94   bb.0:
95     liveins: $sgpr0_sgpr1_sgpr2
96     ; GCN-LABEL: name: trunc_sgpr_s96_to_s16
97     ; GCN: [[COPY:%[0-9]+]]:sgpr_96 = COPY $sgpr0_sgpr1_sgpr2
98     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
99     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
100     %0:sgpr(s96) = COPY $sgpr0_sgpr1_sgpr2
101     %1:sgpr(s16) = G_TRUNC %0
102     S_ENDPGM 0, implicit %1
106 name: trunc_sgpr_s96_to_s64
107 legalized:       true
108 regBankSelected: true
110 body: |
111   bb.0:
112     liveins: $sgpr0_sgpr1_sgpr2
113     ; GCN-LABEL: name: trunc_sgpr_s96_to_s64
114     ; GCN: [[COPY:%[0-9]+]]:sgpr_96_with_sub0_sub1 = COPY $sgpr0_sgpr1_sgpr2
115     ; GCN: [[COPY1:%[0-9]+]]:sreg_64 = COPY [[COPY]].sub0_sub1
116     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
117     %0:sgpr(s96) = COPY $sgpr0_sgpr1_sgpr2
118     %1:sgpr(s64) = G_TRUNC %0
119     S_ENDPGM 0, implicit %1
123 name: trunc_sgpr_s128_to_s16
124 legalized:       true
125 regBankSelected: true
127 body: |
128   bb.0:
129     liveins: $sgpr0_sgpr1_sgpr2_sgpr3
130     ; GCN-LABEL: name: trunc_sgpr_s128_to_s16
131     ; GCN: [[COPY:%[0-9]+]]:sgpr_128 = COPY $sgpr0_sgpr1_sgpr2_sgpr3
132     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[COPY]].sub0
133     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
134     %0:sgpr(s128) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
135     %1:sgpr(s16) = G_TRUNC %0
136     S_ENDPGM 0, implicit %1
140 name: trunc_sgpr_s128_to_s96
141 legalized:       true
142 regBankSelected: true
144 body: |
145   bb.0:
146     liveins: $sgpr0_sgpr1_sgpr2_sgpr3
147     ; GCN-LABEL: name: trunc_sgpr_s128_to_s96
148     ; GCN: [[COPY:%[0-9]+]]:sgpr_128_with_sub0_sub1_sub2 = COPY $sgpr0_sgpr1_sgpr2_sgpr3
149     ; GCN: [[COPY1:%[0-9]+]]:sgpr_96 = COPY [[COPY]].sub0_sub1_sub2
150     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
151     %0:sgpr(s128) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
152     %1:sgpr(s96) = G_TRUNC %0
153     S_ENDPGM 0, implicit %1
157 name: trunc_sgpr_s256_to_s128
158 legalized:       true
159 regBankSelected: true
161 body: |
162   bb.0:
163     liveins: $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7
164     ; GCN-LABEL: name: trunc_sgpr_s256_to_s128
165     ; GCN: [[COPY:%[0-9]+]]:sgpr_256 = COPY $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7
166     ; GCN: [[COPY1:%[0-9]+]]:sgpr_128 = COPY [[COPY]].sub0_sub1_sub2_sub3
167     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
168     %0:sgpr(s256) = COPY $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7
169     %1:sgpr(s128) = G_TRUNC %0
170     S_ENDPGM 0, implicit %1
174 name: trunc_sgpr_s512_to_s256
175 legalized:       true
176 regBankSelected: true
178 body: |
179   bb.0:
180     liveins: $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7_sgpr8_sgpr9_sgpr10_sgpr11_sgpr12_sgpr13_sgpr14_sgpr15
181     ; GCN-LABEL: name: trunc_sgpr_s512_to_s256
182     ; GCN: [[COPY:%[0-9]+]]:sgpr_512 = COPY $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7_sgpr8_sgpr9_sgpr10_sgpr11_sgpr12_sgpr13_sgpr14_sgpr15
183     ; GCN: [[COPY1:%[0-9]+]]:sgpr_256 = COPY [[COPY]].sub0_sub1_sub2_sub3_sub4_sub5_sub6_sub7
184     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
185     %0:sgpr(s512) = COPY $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7_sgpr8_sgpr9_sgpr10_sgpr11_sgpr12_sgpr13_sgpr14_sgpr15
186     %1:sgpr(s256) = G_TRUNC %0
187     S_ENDPGM 0, implicit %1
191 name: trunc_vgpr_s32_to_s1
192 legalized:       true
193 regBankSelected: true
195 body: |
196   bb.0:
197     liveins: $vgpr0
198     ; GCN-LABEL: name: trunc_vgpr_s32_to_s1
199     ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
200     ; GCN: S_ENDPGM 0, implicit [[COPY]]
201     %0:vgpr(s32) = COPY $vgpr0
202     %1:vgpr(s1) = G_TRUNC %0
203     S_ENDPGM 0, implicit %1
207 name: trunc_vgpr_s32_to_s16
208 legalized:       true
209 regBankSelected: true
211 body: |
212   bb.0:
213     liveins: $vgpr0
214     ; GCN-LABEL: name: trunc_vgpr_s32_to_s16
215     ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
216     ; GCN: S_ENDPGM 0, implicit [[COPY]]
217     %0:vgpr(s32) = COPY $vgpr0
218     %1:vgpr(s16) = G_TRUNC %0
219     S_ENDPGM 0, implicit %1
223 name: trunc_vgpr_s64_to_s32
224 legalized:       true
225 regBankSelected: true
227 body: |
228   bb.0:
229     liveins: $vgpr0_vgpr1
230     ; GCN-LABEL: name: trunc_vgpr_s64_to_s32
231     ; GCN: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
232     ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[COPY]].sub0
233     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
234     %0:vgpr(s64) = COPY $vgpr0_vgpr1
235     %1:vgpr(s32) = G_TRUNC %0
236     S_ENDPGM 0, implicit %1
240 name: trunc_vgpr_s64_to_s16
241 legalized:       true
242 regBankSelected: true
244 body: |
245   bb.0:
246     liveins: $vgpr0_vgpr1
247     ; GCN-LABEL: name: trunc_vgpr_s64_to_s16
248     ; GCN: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
249     ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[COPY]].sub0
250     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
251     %0:vgpr(s64) = COPY $vgpr0_vgpr1
252     %1:vgpr(s16) = G_TRUNC %0
253     S_ENDPGM 0, implicit %1
257 name: trunc_vgpr_s64_to_s1
258 legalized:       true
259 regBankSelected: true
261 body: |
262   bb.0:
263     liveins: $vgpr0_vgpr1
264     ; GCN-LABEL: name: trunc_vgpr_s64_to_s1
265     ; GCN: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
266     ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[COPY]].sub0
267     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
268     %0:vgpr(s64) = COPY $vgpr0_vgpr1
269     %1:vgpr(s1) = G_TRUNC %0
270     S_ENDPGM 0, implicit %1
274 name: trunc_vgpr_s96_to_s16
275 legalized:       true
276 regBankSelected: true
278 body: |
279   bb.0:
280     liveins: $vgpr0_vgpr1_vgpr2
281     ; GCN-LABEL: name: trunc_vgpr_s96_to_s16
282     ; GCN: [[COPY:%[0-9]+]]:vreg_96 = COPY $vgpr0_vgpr1_vgpr2
283     ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[COPY]].sub0
284     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
285     %0:vgpr(s96) = COPY $vgpr0_vgpr1_vgpr2
286     %1:vgpr(s16) = G_TRUNC %0
287     S_ENDPGM 0, implicit %1
291 name: trunc_vgpr_s96_to_s64
292 legalized:       true
293 regBankSelected: true
295 body: |
296   bb.0:
297     liveins: $vgpr0_vgpr1_vgpr2
298     ; GCN-LABEL: name: trunc_vgpr_s96_to_s64
299     ; GCN: [[COPY:%[0-9]+]]:vreg_96 = COPY $vgpr0_vgpr1_vgpr2
300     ; GCN: [[COPY1:%[0-9]+]]:vreg_64 = COPY [[COPY]].sub0_sub1
301     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
302     %0:vgpr(s96) = COPY $vgpr0_vgpr1_vgpr2
303     %1:vgpr(s64) = G_TRUNC %0
304     S_ENDPGM 0, implicit %1
308 name: trunc_vgpr_s128_to_s16
309 legalized:       true
310 regBankSelected: true
312 body: |
313   bb.0:
314     liveins: $vgpr0_vgpr1_vgpr2_vgpr3
315     ; GCN-LABEL: name: trunc_vgpr_s128_to_s16
316     ; GCN: [[COPY:%[0-9]+]]:vreg_128 = COPY $vgpr0_vgpr1_vgpr2_vgpr3
317     ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[COPY]].sub0
318     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
319     %0:vgpr(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
320     %1:vgpr(s16) = G_TRUNC %0
321     S_ENDPGM 0, implicit %1
325 name: trunc_vgpr_s128_to_s96
326 legalized:       true
327 regBankSelected: true
329 body: |
330   bb.0:
331     liveins: $vgpr0_vgpr1_vgpr2_vgpr3
332     ; GCN-LABEL: name: trunc_vgpr_s128_to_s96
333     ; GCN: [[COPY:%[0-9]+]]:vreg_128 = COPY $vgpr0_vgpr1_vgpr2_vgpr3
334     ; GCN: [[COPY1:%[0-9]+]]:vreg_96 = COPY [[COPY]].sub0_sub1_sub2
335     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
336     %0:vgpr(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
337     %1:vgpr(s96) = G_TRUNC %0
338     S_ENDPGM 0, implicit %1
342 name: trunc_vgpr_s256_to_s128
343 legalized:       true
344 regBankSelected: true
346 body: |
347   bb.0:
348     liveins: $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
349     ; GCN-LABEL: name: trunc_vgpr_s256_to_s128
350     ; GCN: [[COPY:%[0-9]+]]:vreg_256 = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
351     ; GCN: [[COPY1:%[0-9]+]]:vreg_128 = COPY [[COPY]].sub0_sub1_sub2_sub3
352     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
353     %0:vgpr(s256) = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
354     %1:vgpr(s128) = G_TRUNC %0
355     S_ENDPGM 0, implicit %1
359 name: trunc_vgpr_s512_to_s256
360 legalized:       true
361 regBankSelected: true
363 body: |
364   bb.0:
365     liveins: $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14_vgpr15
366     ; GCN-LABEL: name: trunc_vgpr_s512_to_s256
367     ; GCN: [[COPY:%[0-9]+]]:vreg_512 = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14_vgpr15
368     ; GCN: [[COPY1:%[0-9]+]]:vreg_256 = COPY [[COPY]].sub0_sub1_sub2_sub3_sub4_sub5_sub6_sub7
369     ; GCN: S_ENDPGM 0, implicit [[COPY1]]
370     %0:vgpr(s512) = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14_vgpr15
371     %1:vgpr(s256) = G_TRUNC %0
372     S_ENDPGM 0, implicit %1
377 name: trunc_sgpr_s32_to_s1_use
378 legalized:       true
379 regBankSelected: true
381 body: |
382   bb.0:
383     liveins: $sgpr0, $sgpr1
384     ; GCN-LABEL: name: trunc_sgpr_s32_to_s1_use
385     ; GCN: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
386     ; GCN: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
387     ; GCN: $scc = COPY [[COPY]]
388     ; GCN: [[S_CSELECT_B32_:%[0-9]+]]:sreg_32 = S_CSELECT_B32 [[COPY]], [[COPY1]], implicit $scc
389     ; GCN: S_ENDPGM 0, implicit [[S_CSELECT_B32_]]
390     %0:sgpr(s32) = COPY $sgpr0
391     %1:sgpr(s32) = COPY $sgpr1
392     %2:sgpr(s1) = G_TRUNC %0
393     %3:sgpr(s32) = G_SELECT %2, %0, %1
394     S_ENDPGM 0, implicit %3