1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; Test sext/zext/trunc
7 define i8 @sext_i1_to_i8(i1 %a) {
8 ; LA32-LABEL: sext_i1_to_i8:
10 ; LA32-NEXT: andi $a0, $a0, 1
11 ; LA32-NEXT: sub.w $a0, $zero, $a0
14 ; LA64-LABEL: sext_i1_to_i8:
16 ; LA64-NEXT: andi $a0, $a0, 1
17 ; LA64-NEXT: sub.d $a0, $zero, $a0
23 define i16 @sext_i1_to_i16(i1 %a) {
24 ; LA32-LABEL: sext_i1_to_i16:
26 ; LA32-NEXT: andi $a0, $a0, 1
27 ; LA32-NEXT: sub.w $a0, $zero, $a0
30 ; LA64-LABEL: sext_i1_to_i16:
32 ; LA64-NEXT: andi $a0, $a0, 1
33 ; LA64-NEXT: sub.d $a0, $zero, $a0
35 %1 = sext i1 %a to i16
39 define i32 @sext_i1_to_i32(i1 %a) {
40 ; LA32-LABEL: sext_i1_to_i32:
42 ; LA32-NEXT: andi $a0, $a0, 1
43 ; LA32-NEXT: sub.w $a0, $zero, $a0
46 ; LA64-LABEL: sext_i1_to_i32:
48 ; LA64-NEXT: andi $a0, $a0, 1
49 ; LA64-NEXT: sub.d $a0, $zero, $a0
51 %1 = sext i1 %a to i32
55 define i64 @sext_i1_to_i64(i1 %a) {
56 ; LA32-LABEL: sext_i1_to_i64:
58 ; LA32-NEXT: andi $a0, $a0, 1
59 ; LA32-NEXT: sub.w $a0, $zero, $a0
60 ; LA32-NEXT: move $a1, $a0
63 ; LA64-LABEL: sext_i1_to_i64:
65 ; LA64-NEXT: andi $a0, $a0, 1
66 ; LA64-NEXT: sub.d $a0, $zero, $a0
68 %1 = sext i1 %a to i64
72 define i16 @sext_i8_to_i16(i8 %a) {
73 ; LA32-LABEL: sext_i8_to_i16:
75 ; LA32-NEXT: ext.w.b $a0, $a0
78 ; LA64-LABEL: sext_i8_to_i16:
80 ; LA64-NEXT: ext.w.b $a0, $a0
82 %1 = sext i8 %a to i16
86 define i32 @sext_i8_to_i32(i8 %a) {
87 ; LA32-LABEL: sext_i8_to_i32:
89 ; LA32-NEXT: ext.w.b $a0, $a0
92 ; LA64-LABEL: sext_i8_to_i32:
94 ; LA64-NEXT: ext.w.b $a0, $a0
96 %1 = sext i8 %a to i32
100 define i64 @sext_i8_to_i64(i8 %a) {
101 ; LA32-LABEL: sext_i8_to_i64:
103 ; LA32-NEXT: ext.w.b $a0, $a0
104 ; LA32-NEXT: srai.w $a1, $a0, 31
107 ; LA64-LABEL: sext_i8_to_i64:
109 ; LA64-NEXT: ext.w.b $a0, $a0
111 %1 = sext i8 %a to i64
115 define i32 @sext_i16_to_i32(i16 %a) {
116 ; LA32-LABEL: sext_i16_to_i32:
118 ; LA32-NEXT: ext.w.h $a0, $a0
121 ; LA64-LABEL: sext_i16_to_i32:
123 ; LA64-NEXT: ext.w.h $a0, $a0
125 %1 = sext i16 %a to i32
129 define i64 @sext_i16_to_i64(i16 %a) {
130 ; LA32-LABEL: sext_i16_to_i64:
132 ; LA32-NEXT: ext.w.h $a0, $a0
133 ; LA32-NEXT: srai.w $a1, $a0, 31
136 ; LA64-LABEL: sext_i16_to_i64:
138 ; LA64-NEXT: ext.w.h $a0, $a0
140 %1 = sext i16 %a to i64
144 define i64 @sext_i32_to_i64(i32 %a) {
145 ; LA32-LABEL: sext_i32_to_i64:
147 ; LA32-NEXT: srai.w $a1, $a0, 31
150 ; LA64-LABEL: sext_i32_to_i64:
152 ; LA64-NEXT: addi.w $a0, $a0, 0
154 %1 = sext i32 %a to i64
158 define i8 @zext_i1_to_i8(i1 %a) {
159 ; LA32-LABEL: zext_i1_to_i8:
161 ; LA32-NEXT: andi $a0, $a0, 1
164 ; LA64-LABEL: zext_i1_to_i8:
166 ; LA64-NEXT: andi $a0, $a0, 1
168 %1 = zext i1 %a to i8
172 define i16 @zext_i1_to_i16(i1 %a) {
173 ; LA32-LABEL: zext_i1_to_i16:
175 ; LA32-NEXT: andi $a0, $a0, 1
178 ; LA64-LABEL: zext_i1_to_i16:
180 ; LA64-NEXT: andi $a0, $a0, 1
182 %1 = zext i1 %a to i16
186 define i32 @zext_i1_to_i32(i1 %a) {
187 ; LA32-LABEL: zext_i1_to_i32:
189 ; LA32-NEXT: andi $a0, $a0, 1
192 ; LA64-LABEL: zext_i1_to_i32:
194 ; LA64-NEXT: andi $a0, $a0, 1
196 %1 = zext i1 %a to i32
200 define i64 @zext_i1_to_i64(i1 %a) {
201 ; LA32-LABEL: zext_i1_to_i64:
203 ; LA32-NEXT: andi $a0, $a0, 1
204 ; LA32-NEXT: move $a1, $zero
207 ; LA64-LABEL: zext_i1_to_i64:
209 ; LA64-NEXT: andi $a0, $a0, 1
211 %1 = zext i1 %a to i64
215 define i16 @zext_i8_to_i16(i8 %a) {
216 ; LA32-LABEL: zext_i8_to_i16:
218 ; LA32-NEXT: andi $a0, $a0, 255
221 ; LA64-LABEL: zext_i8_to_i16:
223 ; LA64-NEXT: andi $a0, $a0, 255
225 %1 = zext i8 %a to i16
229 define i32 @zext_i8_to_i32(i8 %a) {
230 ; LA32-LABEL: zext_i8_to_i32:
232 ; LA32-NEXT: andi $a0, $a0, 255
235 ; LA64-LABEL: zext_i8_to_i32:
237 ; LA64-NEXT: andi $a0, $a0, 255
239 %1 = zext i8 %a to i32
243 define i64 @zext_i8_to_i64(i8 %a) {
244 ; LA32-LABEL: zext_i8_to_i64:
246 ; LA32-NEXT: andi $a0, $a0, 255
247 ; LA32-NEXT: move $a1, $zero
250 ; LA64-LABEL: zext_i8_to_i64:
252 ; LA64-NEXT: andi $a0, $a0, 255
254 %1 = zext i8 %a to i64
258 define i32 @zext_i16_to_i32(i16 %a) {
259 ; LA32-LABEL: zext_i16_to_i32:
261 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
264 ; LA64-LABEL: zext_i16_to_i32:
266 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
268 %1 = zext i16 %a to i32
272 define i64 @zext_i16_to_i64(i16 %a) {
273 ; LA32-LABEL: zext_i16_to_i64:
275 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
276 ; LA32-NEXT: move $a1, $zero
279 ; LA64-LABEL: zext_i16_to_i64:
281 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
283 %1 = zext i16 %a to i64
287 define i64 @zext_i32_to_i64(i32 %a) {
288 ; LA32-LABEL: zext_i32_to_i64:
290 ; LA32-NEXT: move $a1, $zero
293 ; LA64-LABEL: zext_i32_to_i64:
295 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 0
297 %1 = zext i32 %a to i64
301 define i1 @trunc_i8_to_i1(i8 %a) {
302 ; LA32-LABEL: trunc_i8_to_i1:
306 ; LA64-LABEL: trunc_i8_to_i1:
309 %1 = trunc i8 %a to i1
313 define i1 @trunc_i16_to_i1(i16 %a) {
314 ; LA32-LABEL: trunc_i16_to_i1:
318 ; LA64-LABEL: trunc_i16_to_i1:
321 %1 = trunc i16 %a to i1
325 define i1 @trunc_i32_to_i1(i32 %a) {
326 ; LA32-LABEL: trunc_i32_to_i1:
330 ; LA64-LABEL: trunc_i32_to_i1:
333 %1 = trunc i32 %a to i1
337 define i1 @trunc_i64_to_i1(i64 %a) {
338 ; LA32-LABEL: trunc_i64_to_i1:
342 ; LA64-LABEL: trunc_i64_to_i1:
345 %1 = trunc i64 %a to i1
349 define i8 @trunc_i16_to_i8(i16 %a) {
350 ; LA32-LABEL: trunc_i16_to_i8:
354 ; LA64-LABEL: trunc_i16_to_i8:
357 %1 = trunc i16 %a to i8
361 define i8 @trunc_i32_to_i8(i32 %a) {
362 ; LA32-LABEL: trunc_i32_to_i8:
366 ; LA64-LABEL: trunc_i32_to_i8:
369 %1 = trunc i32 %a to i8
373 define i8 @trunc_i64_to_i8(i64 %a) {
374 ; LA32-LABEL: trunc_i64_to_i8:
378 ; LA64-LABEL: trunc_i64_to_i8:
381 %1 = trunc i64 %a to i8
385 define i16 @trunc_i32_to_i16(i32 %a) {
386 ; LA32-LABEL: trunc_i32_to_i16:
390 ; LA64-LABEL: trunc_i32_to_i16:
393 %1 = trunc i32 %a to i16
397 define i16 @trunc_i64_to_i16(i64 %a) {
398 ; LA32-LABEL: trunc_i64_to_i16:
402 ; LA64-LABEL: trunc_i64_to_i16:
405 %1 = trunc i64 %a to i16
409 define i32 @trunc_i64_to_i32(i64 %a) {
410 ; LA32-LABEL: trunc_i64_to_i32:
414 ; LA64-LABEL: trunc_i64_to_i32:
417 %1 = trunc i64 %a to i32