1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32I
4 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64I
7 define i8 @sext_i1_to_i8(i1 %a) nounwind {
8 ; RV32I-LABEL: sext_i1_to_i8:
10 ; RV32I-NEXT: andi a0, a0, 1
11 ; RV32I-NEXT: neg a0, a0
14 ; RV64I-LABEL: sext_i1_to_i8:
16 ; RV64I-NEXT: andi a0, a0, 1
17 ; RV64I-NEXT: neg a0, a0
23 define i16 @sext_i1_to_i16(i1 %a) nounwind {
24 ; RV32I-LABEL: sext_i1_to_i16:
26 ; RV32I-NEXT: andi a0, a0, 1
27 ; RV32I-NEXT: neg a0, a0
30 ; RV64I-LABEL: sext_i1_to_i16:
32 ; RV64I-NEXT: andi a0, a0, 1
33 ; RV64I-NEXT: neg a0, a0
35 %1 = sext i1 %a to i16
39 define i32 @sext_i1_to_i32(i1 %a) nounwind {
40 ; RV32I-LABEL: sext_i1_to_i32:
42 ; RV32I-NEXT: andi a0, a0, 1
43 ; RV32I-NEXT: neg a0, a0
46 ; RV64I-LABEL: sext_i1_to_i32:
48 ; RV64I-NEXT: andi a0, a0, 1
49 ; RV64I-NEXT: neg a0, a0
51 %1 = sext i1 %a to i32
55 define i64 @sext_i1_to_i64(i1 %a) nounwind {
56 ; RV32I-LABEL: sext_i1_to_i64:
58 ; RV32I-NEXT: andi a0, a0, 1
59 ; RV32I-NEXT: neg a0, a0
60 ; RV32I-NEXT: mv a1, a0
63 ; RV64I-LABEL: sext_i1_to_i64:
65 ; RV64I-NEXT: andi a0, a0, 1
66 ; RV64I-NEXT: neg a0, a0
68 %1 = sext i1 %a to i64
72 define i16 @sext_i8_to_i16(i8 %a) nounwind {
73 ; RV32I-LABEL: sext_i8_to_i16:
75 ; RV32I-NEXT: slli a0, a0, 24
76 ; RV32I-NEXT: srai a0, a0, 24
79 ; RV64I-LABEL: sext_i8_to_i16:
81 ; RV64I-NEXT: slli a0, a0, 56
82 ; RV64I-NEXT: srai a0, a0, 56
84 %1 = sext i8 %a to i16
88 define i32 @sext_i8_to_i32(i8 %a) nounwind {
89 ; RV32I-LABEL: sext_i8_to_i32:
91 ; RV32I-NEXT: slli a0, a0, 24
92 ; RV32I-NEXT: srai a0, a0, 24
95 ; RV64I-LABEL: sext_i8_to_i32:
97 ; RV64I-NEXT: slli a0, a0, 56
98 ; RV64I-NEXT: srai a0, a0, 56
100 %1 = sext i8 %a to i32
104 define i64 @sext_i8_to_i64(i8 %a) nounwind {
105 ; RV32I-LABEL: sext_i8_to_i64:
107 ; RV32I-NEXT: slli a1, a0, 24
108 ; RV32I-NEXT: srai a0, a1, 24
109 ; RV32I-NEXT: srai a1, a1, 31
112 ; RV64I-LABEL: sext_i8_to_i64:
114 ; RV64I-NEXT: slli a0, a0, 56
115 ; RV64I-NEXT: srai a0, a0, 56
117 %1 = sext i8 %a to i64
121 define i32 @sext_i16_to_i32(i16 %a) nounwind {
122 ; RV32I-LABEL: sext_i16_to_i32:
124 ; RV32I-NEXT: slli a0, a0, 16
125 ; RV32I-NEXT: srai a0, a0, 16
128 ; RV64I-LABEL: sext_i16_to_i32:
130 ; RV64I-NEXT: slli a0, a0, 48
131 ; RV64I-NEXT: srai a0, a0, 48
133 %1 = sext i16 %a to i32
137 define i64 @sext_i16_to_i64(i16 %a) nounwind {
138 ; RV32I-LABEL: sext_i16_to_i64:
140 ; RV32I-NEXT: slli a1, a0, 16
141 ; RV32I-NEXT: srai a0, a1, 16
142 ; RV32I-NEXT: srai a1, a1, 31
145 ; RV64I-LABEL: sext_i16_to_i64:
147 ; RV64I-NEXT: slli a0, a0, 48
148 ; RV64I-NEXT: srai a0, a0, 48
150 %1 = sext i16 %a to i64
154 define i64 @sext_i32_to_i64(i32 %a) nounwind {
155 ; RV32I-LABEL: sext_i32_to_i64:
157 ; RV32I-NEXT: srai a1, a0, 31
160 ; RV64I-LABEL: sext_i32_to_i64:
162 ; RV64I-NEXT: sext.w a0, a0
164 %1 = sext i32 %a to i64
168 define i8 @zext_i1_to_i8(i1 %a) nounwind {
169 ; RV32I-LABEL: zext_i1_to_i8:
171 ; RV32I-NEXT: andi a0, a0, 1
174 ; RV64I-LABEL: zext_i1_to_i8:
176 ; RV64I-NEXT: andi a0, a0, 1
178 %1 = zext i1 %a to i8
182 define i16 @zext_i1_to_i16(i1 %a) nounwind {
183 ; RV32I-LABEL: zext_i1_to_i16:
185 ; RV32I-NEXT: andi a0, a0, 1
188 ; RV64I-LABEL: zext_i1_to_i16:
190 ; RV64I-NEXT: andi a0, a0, 1
192 %1 = zext i1 %a to i16
196 define i32 @zext_i1_to_i32(i1 %a) nounwind {
197 ; RV32I-LABEL: zext_i1_to_i32:
199 ; RV32I-NEXT: andi a0, a0, 1
202 ; RV64I-LABEL: zext_i1_to_i32:
204 ; RV64I-NEXT: andi a0, a0, 1
206 %1 = zext i1 %a to i32
210 define i64 @zext_i1_to_i64(i1 %a) nounwind {
211 ; RV32I-LABEL: zext_i1_to_i64:
213 ; RV32I-NEXT: andi a0, a0, 1
214 ; RV32I-NEXT: mv a1, zero
217 ; RV64I-LABEL: zext_i1_to_i64:
219 ; RV64I-NEXT: andi a0, a0, 1
221 %1 = zext i1 %a to i64
225 define i16 @zext_i8_to_i16(i8 %a) nounwind {
226 ; RV32I-LABEL: zext_i8_to_i16:
228 ; RV32I-NEXT: andi a0, a0, 255
231 ; RV64I-LABEL: zext_i8_to_i16:
233 ; RV64I-NEXT: andi a0, a0, 255
235 %1 = zext i8 %a to i16
239 define i32 @zext_i8_to_i32(i8 %a) nounwind {
240 ; RV32I-LABEL: zext_i8_to_i32:
242 ; RV32I-NEXT: andi a0, a0, 255
245 ; RV64I-LABEL: zext_i8_to_i32:
247 ; RV64I-NEXT: andi a0, a0, 255
249 %1 = zext i8 %a to i32
253 define i64 @zext_i8_to_i64(i8 %a) nounwind {
254 ; RV32I-LABEL: zext_i8_to_i64:
256 ; RV32I-NEXT: andi a0, a0, 255
257 ; RV32I-NEXT: mv a1, zero
260 ; RV64I-LABEL: zext_i8_to_i64:
262 ; RV64I-NEXT: andi a0, a0, 255
264 %1 = zext i8 %a to i64
268 define i32 @zext_i16_to_i32(i16 %a) nounwind {
269 ; RV32I-LABEL: zext_i16_to_i32:
271 ; RV32I-NEXT: lui a1, 16
272 ; RV32I-NEXT: addi a1, a1, -1
273 ; RV32I-NEXT: and a0, a0, a1
276 ; RV64I-LABEL: zext_i16_to_i32:
278 ; RV64I-NEXT: lui a1, 16
279 ; RV64I-NEXT: addiw a1, a1, -1
280 ; RV64I-NEXT: and a0, a0, a1
282 %1 = zext i16 %a to i32
286 define i64 @zext_i16_to_i64(i16 %a) nounwind {
287 ; RV32I-LABEL: zext_i16_to_i64:
289 ; RV32I-NEXT: lui a1, 16
290 ; RV32I-NEXT: addi a1, a1, -1
291 ; RV32I-NEXT: and a0, a0, a1
292 ; RV32I-NEXT: mv a1, zero
295 ; RV64I-LABEL: zext_i16_to_i64:
297 ; RV64I-NEXT: lui a1, 16
298 ; RV64I-NEXT: addiw a1, a1, -1
299 ; RV64I-NEXT: and a0, a0, a1
301 %1 = zext i16 %a to i64
305 define i64 @zext_i32_to_i64(i32 %a) nounwind {
306 ; RV32I-LABEL: zext_i32_to_i64:
308 ; RV32I-NEXT: mv a1, zero
311 ; RV64I-LABEL: zext_i32_to_i64:
313 ; RV64I-NEXT: slli a0, a0, 32
314 ; RV64I-NEXT: srli a0, a0, 32
316 %1 = zext i32 %a to i64
320 define i1 @trunc_i8_to_i1(i8 %a) nounwind {
321 ; RV32I-LABEL: trunc_i8_to_i1:
325 ; RV64I-LABEL: trunc_i8_to_i1:
328 %1 = trunc i8 %a to i1
332 define i1 @trunc_i16_to_i1(i16 %a) nounwind {
333 ; RV32I-LABEL: trunc_i16_to_i1:
337 ; RV64I-LABEL: trunc_i16_to_i1:
340 %1 = trunc i16 %a to i1
344 define i1 @trunc_i32_to_i1(i32 %a) nounwind {
345 ; RV32I-LABEL: trunc_i32_to_i1:
349 ; RV64I-LABEL: trunc_i32_to_i1:
352 %1 = trunc i32 %a to i1
356 define i1 @trunc_i64_to_i1(i64 %a) nounwind {
357 ; RV32I-LABEL: trunc_i64_to_i1:
361 ; RV64I-LABEL: trunc_i64_to_i1:
364 %1 = trunc i64 %a to i1
368 define i8 @trunc_i16_to_i8(i16 %a) nounwind {
369 ; RV32I-LABEL: trunc_i16_to_i8:
373 ; RV64I-LABEL: trunc_i16_to_i8:
376 %1 = trunc i16 %a to i8
380 define i8 @trunc_i32_to_i8(i32 %a) nounwind {
381 ; RV32I-LABEL: trunc_i32_to_i8:
385 ; RV64I-LABEL: trunc_i32_to_i8:
388 %1 = trunc i32 %a to i8
392 define i8 @trunc_i64_to_i8(i64 %a) nounwind {
393 ; RV32I-LABEL: trunc_i64_to_i8:
397 ; RV64I-LABEL: trunc_i64_to_i8:
400 %1 = trunc i64 %a to i8
404 define i16 @trunc_i32_to_i16(i32 %a) nounwind {
405 ; RV32I-LABEL: trunc_i32_to_i16:
409 ; RV64I-LABEL: trunc_i32_to_i16:
412 %1 = trunc i32 %a to i16
416 define i16 @trunc_i64_to_i16(i64 %a) nounwind {
417 ; RV32I-LABEL: trunc_i64_to_i16:
421 ; RV64I-LABEL: trunc_i64_to_i16:
424 %1 = trunc i64 %a to i16
428 define i32 @trunc_i64_to_i32(i64 %a) nounwind {
429 ; RV32I-LABEL: trunc_i64_to_i32:
433 ; RV64I-LABEL: trunc_i64_to_i32:
436 %1 = trunc i64 %a to i32