1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv32 -run-pass=instruction-select -simplify-mir -verify-machineinstrs %s -o - \
3 # RUN: | FileCheck -check-prefix=RV32I %s
9 tracksRegLiveness: true
14 ; RV32I-LABEL: name: add_i8_signext
15 ; RV32I: liveins: $x10, $x11
17 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
18 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
19 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
20 ; RV32I-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[ADD]], 24
21 ; RV32I-NEXT: [[SRAI:%[0-9]+]]:gpr = SRAI [[SLLI]], 24
22 ; RV32I-NEXT: $x10 = COPY [[SRAI]]
23 ; RV32I-NEXT: PseudoRET implicit $x10
24 %0:gprb(s32) = COPY $x10
25 %1:gprb(s32) = COPY $x11
26 %2:gprb(s32) = G_ADD %0, %1
27 %3:gprb(s32) = G_CONSTANT i32 24
28 %4:gprb(s32) = G_SHL %2, %3(s32)
29 %5:gprb(s32) = G_ASHR %4, %3(s32)
31 PseudoRET implicit $x10
38 tracksRegLiveness: true
43 ; RV32I-LABEL: name: add_i8_zeroext
44 ; RV32I: liveins: $x10, $x11
46 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
47 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
48 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
49 ; RV32I-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[ADD]], 255
50 ; RV32I-NEXT: $x10 = COPY [[ANDI]]
51 ; RV32I-NEXT: PseudoRET implicit $x10
52 %0:gprb(s32) = COPY $x10
53 %1:gprb(s32) = COPY $x11
54 %2:gprb(s32) = G_ADD %0, %1
55 %3:gprb(s32) = G_CONSTANT i32 255
56 %4:gprb(s32) = G_AND %2, %3
58 PseudoRET implicit $x10
65 tracksRegLiveness: true
70 ; RV32I-LABEL: name: add_i16_signext
71 ; RV32I: liveins: $x10, $x11
73 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
74 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
75 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
76 ; RV32I-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[ADD]], 16
77 ; RV32I-NEXT: [[SRAI:%[0-9]+]]:gpr = SRAI [[SLLI]], 16
78 ; RV32I-NEXT: $x10 = COPY [[SRAI]]
79 ; RV32I-NEXT: PseudoRET implicit $x10
80 %0:gprb(s32) = COPY $x10
81 %1:gprb(s32) = COPY $x11
82 %2:gprb(s32) = G_ADD %0, %1
83 %3:gprb(s32) = G_CONSTANT i32 16
84 %4:gprb(s32) = G_SHL %2, %3(s32)
85 %5:gprb(s32) = G_ASHR %4, %3(s32)
87 PseudoRET implicit $x10
94 tracksRegLiveness: true
99 ; RV32I-LABEL: name: add_i16_zeroext
100 ; RV32I: liveins: $x10, $x11
102 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
103 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
104 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
105 ; RV32I-NEXT: [[LUI:%[0-9]+]]:gpr = LUI 16
106 ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[LUI]], -1
107 ; RV32I-NEXT: [[AND:%[0-9]+]]:gpr = AND [[ADD]], [[ADDI]]
108 ; RV32I-NEXT: $x10 = COPY [[AND]]
109 ; RV32I-NEXT: PseudoRET implicit $x10
110 %0:gprb(s32) = COPY $x10
111 %1:gprb(s32) = COPY $x11
112 %2:gprb(s32) = G_ADD %0, %1
113 %3:gprb(s32) = G_CONSTANT i32 65535
114 %4:gprb(s32) = G_AND %2, %3
116 PseudoRET implicit $x10
122 regBankSelected: true
123 tracksRegLiveness: true
128 ; RV32I-LABEL: name: add_i32
129 ; RV32I: liveins: $x10, $x11
131 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
132 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
133 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
134 ; RV32I-NEXT: $x10 = COPY [[ADD]]
135 ; RV32I-NEXT: PseudoRET implicit $x10
136 %0:gprb(s32) = COPY $x10
137 %1:gprb(s32) = COPY $x11
138 %2:gprb(s32) = G_ADD %0, %1
140 PseudoRET implicit $x10
146 regBankSelected: true
147 tracksRegLiveness: true
152 ; RV32I-LABEL: name: addi_i32
153 ; RV32I: liveins: $x10
155 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
156 ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], 1234
157 ; RV32I-NEXT: $x10 = COPY [[ADDI]]
158 ; RV32I-NEXT: PseudoRET implicit $x10
159 %0:gprb(s32) = COPY $x10
160 %1:gprb(s32) = G_CONSTANT i32 1234
161 %2:gprb(s32) = G_ADD %0, %1
163 PseudoRET implicit $x10
169 regBankSelected: true
170 tracksRegLiveness: true
175 ; RV32I-LABEL: name: sub_i32
176 ; RV32I: liveins: $x10, $x11
178 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
179 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
180 ; RV32I-NEXT: [[SUB:%[0-9]+]]:gpr = SUB [[COPY]], [[COPY1]]
181 ; RV32I-NEXT: $x10 = COPY [[SUB]]
182 ; RV32I-NEXT: PseudoRET implicit $x10
183 %0:gprb(s32) = COPY $x10
184 %1:gprb(s32) = COPY $x11
185 %2:gprb(s32) = G_SUB %0, %1
187 PseudoRET implicit $x10
193 regBankSelected: true
194 tracksRegLiveness: true
199 ; RV32I-LABEL: name: subi_i32
200 ; RV32I: liveins: $x10
202 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
203 ; RV32I-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], 1234
204 ; RV32I-NEXT: $x10 = COPY [[ADDI]]
205 ; RV32I-NEXT: PseudoRET implicit $x10
206 %0:gprb(s32) = COPY $x10
207 %1:gprb(s32) = G_CONSTANT i32 -1234
208 %2:gprb(s32) = G_SUB %0, %1
210 PseudoRET implicit $x10
216 regBankSelected: true
217 tracksRegLiveness: true
222 ; RV32I-LABEL: name: sll_i32
223 ; RV32I: liveins: $x10, $x11
225 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
226 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
227 ; RV32I-NEXT: [[SLL:%[0-9]+]]:gpr = SLL [[COPY]], [[COPY1]]
228 ; RV32I-NEXT: $x10 = COPY [[SLL]]
229 ; RV32I-NEXT: PseudoRET implicit $x10
230 %0:gprb(s32) = COPY $x10
231 %1:gprb(s32) = COPY $x11
232 %2:gprb(s32) = G_SHL %0, %1
234 PseudoRET implicit $x10
240 regBankSelected: true
241 tracksRegLiveness: true
246 ; RV32I-LABEL: name: slli_i32
247 ; RV32I: liveins: $x10
249 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
250 ; RV32I-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[COPY]], 31
251 ; RV32I-NEXT: $x10 = COPY [[SLLI]]
252 ; RV32I-NEXT: PseudoRET implicit $x10
253 %0:gprb(s32) = COPY $x10
254 %1:gprb(s32) = G_CONSTANT i32 31
255 %2:gprb(s32) = G_SHL %0, %1
257 PseudoRET implicit $x10
263 regBankSelected: true
264 tracksRegLiveness: true
269 ; RV32I-LABEL: name: sra_i32
270 ; RV32I: liveins: $x10, $x11
272 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
273 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
274 ; RV32I-NEXT: [[SRA:%[0-9]+]]:gpr = SRA [[COPY]], [[COPY1]]
275 ; RV32I-NEXT: $x10 = COPY [[SRA]]
276 ; RV32I-NEXT: PseudoRET implicit $x10
277 %0:gprb(s32) = COPY $x10
278 %1:gprb(s32) = COPY $x11
279 %2:gprb(s32) = G_ASHR %0, %1
281 PseudoRET implicit $x10
287 regBankSelected: true
288 tracksRegLiveness: true
293 ; RV32I-LABEL: name: srai_i32
294 ; RV32I: liveins: $x10
296 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
297 ; RV32I-NEXT: [[SRAI:%[0-9]+]]:gpr = SRAI [[COPY]], 31
298 ; RV32I-NEXT: $x10 = COPY [[SRAI]]
299 ; RV32I-NEXT: PseudoRET implicit $x10
300 %0:gprb(s32) = COPY $x10
301 %1:gprb(s32) = G_CONSTANT i32 31
302 %2:gprb(s32) = G_ASHR %0, %1
304 PseudoRET implicit $x10
310 regBankSelected: true
311 tracksRegLiveness: true
316 ; RV32I-LABEL: name: srl_i32
317 ; RV32I: liveins: $x10, $x11
319 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
320 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
321 ; RV32I-NEXT: [[SRL:%[0-9]+]]:gpr = SRL [[COPY]], [[COPY1]]
322 ; RV32I-NEXT: $x10 = COPY [[SRL]]
323 ; RV32I-NEXT: PseudoRET implicit $x10
324 %0:gprb(s32) = COPY $x10
325 %1:gprb(s32) = COPY $x11
326 %2:gprb(s32) = G_LSHR %0, %1
328 PseudoRET implicit $x10
334 regBankSelected: true
335 tracksRegLiveness: true
340 ; RV32I-LABEL: name: srli_i32
341 ; RV32I: liveins: $x10
343 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
344 ; RV32I-NEXT: [[SRLI:%[0-9]+]]:gpr = SRLI [[COPY]], 31
345 ; RV32I-NEXT: $x10 = COPY [[SRLI]]
346 ; RV32I-NEXT: PseudoRET implicit $x10
347 %0:gprb(s32) = COPY $x10
348 %1:gprb(s32) = G_CONSTANT i32 31
349 %2:gprb(s32) = G_LSHR %0, %1
351 PseudoRET implicit $x10
357 regBankSelected: true
358 tracksRegLiveness: true
363 ; RV32I-LABEL: name: and_i32
364 ; RV32I: liveins: $x10, $x11
366 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
367 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
368 ; RV32I-NEXT: [[AND:%[0-9]+]]:gpr = AND [[COPY]], [[COPY1]]
369 ; RV32I-NEXT: $x10 = COPY [[AND]]
370 ; RV32I-NEXT: PseudoRET implicit $x10
371 %0:gprb(s32) = COPY $x10
372 %1:gprb(s32) = COPY $x11
373 %2:gprb(s32) = G_AND %0, %1
375 PseudoRET implicit $x10
381 regBankSelected: true
382 tracksRegLiveness: true
387 ; RV32I-LABEL: name: andi_i32
388 ; RV32I: liveins: $x10
390 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
391 ; RV32I-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY]], 1234
392 ; RV32I-NEXT: $x10 = COPY [[ANDI]]
393 ; RV32I-NEXT: PseudoRET implicit $x10
394 %0:gprb(s32) = COPY $x10
395 %1:gprb(s32) = G_CONSTANT i32 1234
396 %2:gprb(s32) = G_AND %0, %1
398 PseudoRET implicit $x10
404 regBankSelected: true
405 tracksRegLiveness: true
410 ; RV32I-LABEL: name: or_i32
411 ; RV32I: liveins: $x10, $x11
413 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
414 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
415 ; RV32I-NEXT: [[OR:%[0-9]+]]:gpr = OR [[COPY]], [[COPY1]]
416 ; RV32I-NEXT: $x10 = COPY [[OR]]
417 ; RV32I-NEXT: PseudoRET implicit $x10
418 %0:gprb(s32) = COPY $x10
419 %1:gprb(s32) = COPY $x11
420 %2:gprb(s32) = G_OR %0, %1
422 PseudoRET implicit $x10
428 regBankSelected: true
429 tracksRegLiveness: true
434 ; RV32I-LABEL: name: ori_i32
435 ; RV32I: liveins: $x10
437 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
438 ; RV32I-NEXT: [[ORI:%[0-9]+]]:gpr = ORI [[COPY]], 1234
439 ; RV32I-NEXT: $x10 = COPY [[ORI]]
440 ; RV32I-NEXT: PseudoRET implicit $x10
441 %0:gprb(s32) = COPY $x10
442 %1:gprb(s32) = G_CONSTANT i32 1234
443 %2:gprb(s32) = G_OR %0, %1
445 PseudoRET implicit $x10
451 regBankSelected: true
452 tracksRegLiveness: true
457 ; RV32I-LABEL: name: xor_i32
458 ; RV32I: liveins: $x10, $x11
460 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
461 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
462 ; RV32I-NEXT: [[XOR:%[0-9]+]]:gpr = XOR [[COPY]], [[COPY1]]
463 ; RV32I-NEXT: $x10 = COPY [[XOR]]
464 ; RV32I-NEXT: PseudoRET implicit $x10
465 %0:gprb(s32) = COPY $x10
466 %1:gprb(s32) = COPY $x11
467 %2:gprb(s32) = G_XOR %0, %1
469 PseudoRET implicit $x10
475 regBankSelected: true
476 tracksRegLiveness: true
481 ; RV32I-LABEL: name: xori_i32
482 ; RV32I: liveins: $x10
484 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
485 ; RV32I-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[COPY]], 1234
486 ; RV32I-NEXT: $x10 = COPY [[XORI]]
487 ; RV32I-NEXT: PseudoRET implicit $x10
488 %0:gprb(s32) = COPY $x10
489 %1:gprb(s32) = G_CONSTANT i32 1234
490 %2:gprb(s32) = G_XOR %0, %1
492 PseudoRET implicit $x10
498 regBankSelected: true
499 tracksRegLiveness: true
502 liveins: $x10, $x11, $x12, $x13
504 ; RV32I-LABEL: name: add_i64
505 ; RV32I: liveins: $x10, $x11, $x12, $x13
507 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
508 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
509 ; RV32I-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
510 ; RV32I-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x13
511 ; RV32I-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY2]]
512 ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[ADD]], [[COPY2]]
513 ; RV32I-NEXT: [[ADD1:%[0-9]+]]:gpr = ADD [[COPY1]], [[COPY3]]
514 ; RV32I-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[SLTU]], 1
515 ; RV32I-NEXT: [[ADD2:%[0-9]+]]:gpr = ADD [[ADD1]], [[ANDI]]
516 ; RV32I-NEXT: $x10 = COPY [[ADD]]
517 ; RV32I-NEXT: $x11 = COPY [[ADD2]]
518 ; RV32I-NEXT: PseudoRET implicit $x10, implicit $x11
519 %0:gprb(s32) = COPY $x10
520 %1:gprb(s32) = COPY $x11
521 %2:gprb(s32) = COPY $x12
522 %3:gprb(s32) = COPY $x13
523 %4:gprb(s32) = G_ADD %0, %2
524 %5:gprb(s32) = G_ICMP intpred(ult), %4(s32), %2
525 %6:gprb(s32) = G_ADD %1, %3
526 %7:gprb(s32) = G_CONSTANT i32 1
527 %8:gprb(s32) = G_AND %5, %7
528 %9:gprb(s32) = G_ADD %6, %8
531 PseudoRET implicit $x10, implicit $x11
537 regBankSelected: true
538 tracksRegLiveness: true
541 liveins: $x10, $x11, $x12, $x13
543 ; RV32I-LABEL: name: sub_i64
544 ; RV32I: liveins: $x10, $x11, $x12, $x13
546 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
547 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
548 ; RV32I-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
549 ; RV32I-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x13
550 ; RV32I-NEXT: [[SUB:%[0-9]+]]:gpr = SUB [[COPY]], [[COPY2]]
551 ; RV32I-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU [[COPY]], [[COPY2]]
552 ; RV32I-NEXT: [[SUB1:%[0-9]+]]:gpr = SUB [[COPY1]], [[COPY3]]
553 ; RV32I-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[SLTU]], 1
554 ; RV32I-NEXT: [[SUB2:%[0-9]+]]:gpr = SUB [[SUB1]], [[ANDI]]
555 ; RV32I-NEXT: $x10 = COPY [[SUB]]
556 ; RV32I-NEXT: $x11 = COPY [[SUB2]]
557 ; RV32I-NEXT: PseudoRET implicit $x10, implicit $x11
558 %0:gprb(s32) = COPY $x10
559 %1:gprb(s32) = COPY $x11
560 %2:gprb(s32) = COPY $x12
561 %3:gprb(s32) = COPY $x13
562 %4:gprb(s32) = G_SUB %0, %2
563 %5:gprb(s32) = G_ICMP intpred(ult), %0(s32), %2
564 %6:gprb(s32) = G_SUB %1, %3
565 %7:gprb(s32) = G_CONSTANT i32 1
566 %8:gprb(s32) = G_AND %5, %7
567 %9:gprb(s32) = G_SUB %6, %8
570 PseudoRET implicit $x10, implicit $x11