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 ;; Exercise the 'add' LLVM IR: https://llvm.org/docs/LangRef.html#add-instruction
7 define i1 @add_i1(i1 %x, i1 %y) {
10 ; LA32-NEXT: add.w $a0, $a0, $a1
15 ; LA64-NEXT: add.d $a0, $a0, $a1
21 define i8 @add_i8(i8 %x, i8 %y) {
24 ; LA32-NEXT: add.w $a0, $a0, $a1
29 ; LA64-NEXT: add.d $a0, $a0, $a1
35 define i16 @add_i16(i16 %x, i16 %y) {
36 ; LA32-LABEL: add_i16:
38 ; LA32-NEXT: add.w $a0, $a0, $a1
41 ; LA64-LABEL: add_i16:
43 ; LA64-NEXT: add.d $a0, $a0, $a1
49 define i32 @add_i32(i32 %x, i32 %y) {
50 ; LA32-LABEL: add_i32:
52 ; LA32-NEXT: add.w $a0, $a0, $a1
55 ; LA64-LABEL: add_i32:
57 ; LA64-NEXT: add.w $a0, $a0, $a1
64 ;; def : PatGprGpr_32<add, ADD_W>;
65 define signext i32 @add_i32_sext(i32 %x, i32 %y) {
66 ; LA32-LABEL: add_i32_sext:
68 ; LA32-NEXT: add.w $a0, $a0, $a1
71 ; LA64-LABEL: add_i32_sext:
73 ; LA64-NEXT: add.w $a0, $a0, $a1
79 define i64 @add_i64(i64 %x, i64 %y) {
80 ; LA32-LABEL: add_i64:
82 ; LA32-NEXT: add.w $a1, $a1, $a3
83 ; LA32-NEXT: add.w $a2, $a0, $a2
84 ; LA32-NEXT: sltu $a0, $a2, $a0
85 ; LA32-NEXT: add.w $a1, $a1, $a0
86 ; LA32-NEXT: move $a0, $a2
89 ; LA64-LABEL: add_i64:
91 ; LA64-NEXT: add.d $a0, $a0, $a1
97 define i1 @add_i1_3(i1 %x) {
98 ; LA32-LABEL: add_i1_3:
100 ; LA32-NEXT: addi.w $a0, $a0, 1
103 ; LA64-LABEL: add_i1_3:
105 ; LA64-NEXT: addi.d $a0, $a0, 1
111 define i8 @add_i8_3(i8 %x) {
112 ; LA32-LABEL: add_i8_3:
114 ; LA32-NEXT: addi.w $a0, $a0, 3
117 ; LA64-LABEL: add_i8_3:
119 ; LA64-NEXT: addi.d $a0, $a0, 3
125 define i16 @add_i16_3(i16 %x) {
126 ; LA32-LABEL: add_i16_3:
128 ; LA32-NEXT: addi.w $a0, $a0, 3
131 ; LA64-LABEL: add_i16_3:
133 ; LA64-NEXT: addi.d $a0, $a0, 3
139 define i32 @add_i32_3(i32 %x) {
140 ; LA32-LABEL: add_i32_3:
142 ; LA32-NEXT: addi.w $a0, $a0, 3
145 ; LA64-LABEL: add_i32_3:
147 ; LA64-NEXT: addi.w $a0, $a0, 3
153 ;; Match the pattern:
154 ;; def : PatGprImm_32<add, ADDI_W, simm12>;
155 define signext i32 @add_i32_3_sext(i32 %x) {
156 ; LA32-LABEL: add_i32_3_sext:
158 ; LA32-NEXT: addi.w $a0, $a0, 3
161 ; LA64-LABEL: add_i32_3_sext:
163 ; LA64-NEXT: addi.w $a0, $a0, 3
169 define i64 @add_i64_3(i64 %x) {
170 ; LA32-LABEL: add_i64_3:
172 ; LA32-NEXT: addi.w $a2, $a0, 3
173 ; LA32-NEXT: sltu $a0, $a2, $a0
174 ; LA32-NEXT: add.w $a1, $a1, $a0
175 ; LA32-NEXT: move $a0, $a2
178 ; LA64-LABEL: add_i64_3:
180 ; LA64-NEXT: addi.d $a0, $a0, 3
186 ;; Check that `addu16i.d` is emitted for these cases.
188 define i32 @add_i32_0x12340000(i32 %x) {
189 ; LA32-LABEL: add_i32_0x12340000:
191 ; LA32-NEXT: lu12i.w $a1, 74560
192 ; LA32-NEXT: add.w $a0, $a0, $a1
195 ; LA64-LABEL: add_i32_0x12340000:
197 ; LA64-NEXT: addu16i.d $a0, $a0, 4660
198 ; LA64-NEXT: addi.w $a0, $a0, 0
200 %add = add i32 %x, 305397760
204 define signext i32 @add_i32_0x12340000_sext(i32 %x) {
205 ; LA32-LABEL: add_i32_0x12340000_sext:
207 ; LA32-NEXT: lu12i.w $a1, 74560
208 ; LA32-NEXT: add.w $a0, $a0, $a1
211 ; LA64-LABEL: add_i32_0x12340000_sext:
213 ; LA64-NEXT: addu16i.d $a0, $a0, 4660
214 ; LA64-NEXT: addi.w $a0, $a0, 0
216 %add = add i32 %x, 305397760
220 define i64 @add_i64_0x12340000(i64 %x) {
221 ; LA32-LABEL: add_i64_0x12340000:
223 ; LA32-NEXT: lu12i.w $a2, 74560
224 ; LA32-NEXT: add.w $a2, $a0, $a2
225 ; LA32-NEXT: sltu $a0, $a2, $a0
226 ; LA32-NEXT: add.w $a1, $a1, $a0
227 ; LA32-NEXT: move $a0, $a2
230 ; LA64-LABEL: add_i64_0x12340000:
232 ; LA64-NEXT: addu16i.d $a0, $a0, 4660
234 %add = add i64 %x, 305397760
238 define i32 @add_i32_0x7fff0000(i32 %x) {
239 ; LA32-LABEL: add_i32_0x7fff0000:
241 ; LA32-NEXT: lu12i.w $a1, 524272
242 ; LA32-NEXT: add.w $a0, $a0, $a1
245 ; LA64-LABEL: add_i32_0x7fff0000:
247 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
248 ; LA64-NEXT: addi.w $a0, $a0, 0
250 %add = add i32 %x, 2147418112
254 define signext i32 @add_i32_0x7fff0000_sext(i32 %x) {
255 ; LA32-LABEL: add_i32_0x7fff0000_sext:
257 ; LA32-NEXT: lu12i.w $a1, 524272
258 ; LA32-NEXT: add.w $a0, $a0, $a1
261 ; LA64-LABEL: add_i32_0x7fff0000_sext:
263 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
264 ; LA64-NEXT: addi.w $a0, $a0, 0
266 %add = add i32 %x, 2147418112
270 define i64 @add_i64_0x7fff0000(i64 %x) {
271 ; LA32-LABEL: add_i64_0x7fff0000:
273 ; LA32-NEXT: lu12i.w $a2, 524272
274 ; LA32-NEXT: add.w $a2, $a0, $a2
275 ; LA32-NEXT: sltu $a0, $a2, $a0
276 ; LA32-NEXT: add.w $a1, $a1, $a0
277 ; LA32-NEXT: move $a0, $a2
280 ; LA64-LABEL: add_i64_0x7fff0000:
282 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
284 %add = add i64 %x, 2147418112
288 define i32 @add_i32_minus_0x80000000(i32 %x) {
289 ; LA32-LABEL: add_i32_minus_0x80000000:
291 ; LA32-NEXT: lu12i.w $a1, -524288
292 ; LA32-NEXT: add.w $a0, $a0, $a1
295 ; LA64-LABEL: add_i32_minus_0x80000000:
297 ; LA64-NEXT: addu16i.d $a0, $a0, -32768
298 ; LA64-NEXT: addi.w $a0, $a0, 0
300 %add = add i32 %x, -2147483648
304 define signext i32 @add_i32_minus_0x80000000_sext(i32 %x) {
305 ; LA32-LABEL: add_i32_minus_0x80000000_sext:
307 ; LA32-NEXT: lu12i.w $a1, -524288
308 ; LA32-NEXT: add.w $a0, $a0, $a1
311 ; LA64-LABEL: add_i32_minus_0x80000000_sext:
313 ; LA64-NEXT: addu16i.d $a0, $a0, -32768
314 ; LA64-NEXT: addi.w $a0, $a0, 0
316 %add = add i32 %x, -2147483648
320 define i64 @add_i64_minus_0x80000000(i64 %x) {
321 ; LA32-LABEL: add_i64_minus_0x80000000:
323 ; LA32-NEXT: lu12i.w $a2, -524288
324 ; LA32-NEXT: add.w $a2, $a0, $a2
325 ; LA32-NEXT: sltu $a0, $a2, $a0
326 ; LA32-NEXT: add.w $a0, $a1, $a0
327 ; LA32-NEXT: addi.w $a1, $a0, -1
328 ; LA32-NEXT: move $a0, $a2
331 ; LA64-LABEL: add_i64_minus_0x80000000:
333 ; LA64-NEXT: addu16i.d $a0, $a0, -32768
335 %add = add i64 %x, -2147483648
339 define i32 @add_i32_minus_0x10000(i32 %x) {
340 ; LA32-LABEL: add_i32_minus_0x10000:
342 ; LA32-NEXT: lu12i.w $a1, -16
343 ; LA32-NEXT: add.w $a0, $a0, $a1
346 ; LA64-LABEL: add_i32_minus_0x10000:
348 ; LA64-NEXT: addu16i.d $a0, $a0, -1
349 ; LA64-NEXT: addi.w $a0, $a0, 0
351 %add = add i32 %x, -65536
355 define signext i32 @add_i32_minus_0x10000_sext(i32 %x) {
356 ; LA32-LABEL: add_i32_minus_0x10000_sext:
358 ; LA32-NEXT: lu12i.w $a1, -16
359 ; LA32-NEXT: add.w $a0, $a0, $a1
362 ; LA64-LABEL: add_i32_minus_0x10000_sext:
364 ; LA64-NEXT: addu16i.d $a0, $a0, -1
365 ; LA64-NEXT: addi.w $a0, $a0, 0
367 %add = add i32 %x, -65536
371 define i64 @add_i64_minus_0x10000(i64 %x) {
372 ; LA32-LABEL: add_i64_minus_0x10000:
374 ; LA32-NEXT: lu12i.w $a2, -16
375 ; LA32-NEXT: add.w $a2, $a0, $a2
376 ; LA32-NEXT: sltu $a0, $a2, $a0
377 ; LA32-NEXT: add.w $a0, $a1, $a0
378 ; LA32-NEXT: addi.w $a1, $a0, -1
379 ; LA32-NEXT: move $a0, $a2
382 ; LA64-LABEL: add_i64_minus_0x10000:
384 ; LA64-NEXT: addu16i.d $a0, $a0, -1
386 %add = add i64 %x, -65536
390 ;; Check that `addu16i.d + addi` is emitted for these cases.
392 define i32 @add_i32_0x7fff07ff(i32 %x) {
393 ; LA32-LABEL: add_i32_0x7fff07ff:
395 ; LA32-NEXT: lu12i.w $a1, 524272
396 ; LA32-NEXT: ori $a1, $a1, 2047
397 ; LA32-NEXT: add.w $a0, $a0, $a1
400 ; LA64-LABEL: add_i32_0x7fff07ff:
402 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
403 ; LA64-NEXT: addi.w $a0, $a0, 2047
405 %add = add i32 %x, 2147420159
409 define signext i32 @add_i32_0x7fff07ff_sext(i32 %x) {
410 ; LA32-LABEL: add_i32_0x7fff07ff_sext:
412 ; LA32-NEXT: lu12i.w $a1, 524272
413 ; LA32-NEXT: ori $a1, $a1, 2047
414 ; LA32-NEXT: add.w $a0, $a0, $a1
417 ; LA64-LABEL: add_i32_0x7fff07ff_sext:
419 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
420 ; LA64-NEXT: addi.w $a0, $a0, 2047
422 %add = add i32 %x, 2147420159
426 define i64 @add_i64_0x7fff07ff(i64 %x) {
427 ; LA32-LABEL: add_i64_0x7fff07ff:
429 ; LA32-NEXT: lu12i.w $a2, 524272
430 ; LA32-NEXT: ori $a2, $a2, 2047
431 ; LA32-NEXT: add.w $a2, $a0, $a2
432 ; LA32-NEXT: sltu $a0, $a2, $a0
433 ; LA32-NEXT: add.w $a1, $a1, $a0
434 ; LA32-NEXT: move $a0, $a2
437 ; LA64-LABEL: add_i64_0x7fff07ff:
439 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
440 ; LA64-NEXT: addi.d $a0, $a0, 2047
442 %add = add i64 %x, 2147420159
446 define i32 @add_i32_0x7ffef800(i32 %x) {
447 ; LA32-LABEL: add_i32_0x7ffef800:
449 ; LA32-NEXT: lu12i.w $a1, 524271
450 ; LA32-NEXT: ori $a1, $a1, 2048
451 ; LA32-NEXT: add.w $a0, $a0, $a1
454 ; LA64-LABEL: add_i32_0x7ffef800:
456 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
457 ; LA64-NEXT: addi.w $a0, $a0, -2048
459 %add = add i32 %x, 2147416064
463 define signext i32 @add_i32_0x7ffef800_sext(i32 %x) {
464 ; LA32-LABEL: add_i32_0x7ffef800_sext:
466 ; LA32-NEXT: lu12i.w $a1, 524271
467 ; LA32-NEXT: ori $a1, $a1, 2048
468 ; LA32-NEXT: add.w $a0, $a0, $a1
471 ; LA64-LABEL: add_i32_0x7ffef800_sext:
473 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
474 ; LA64-NEXT: addi.w $a0, $a0, -2048
476 %add = add i32 %x, 2147416064
480 define i64 @add_i64_0x7ffef800(i64 %x) {
481 ; LA32-LABEL: add_i64_0x7ffef800:
483 ; LA32-NEXT: lu12i.w $a2, 524271
484 ; LA32-NEXT: ori $a2, $a2, 2048
485 ; LA32-NEXT: add.w $a2, $a0, $a2
486 ; LA32-NEXT: sltu $a0, $a2, $a0
487 ; LA32-NEXT: add.w $a1, $a1, $a0
488 ; LA32-NEXT: move $a0, $a2
491 ; LA64-LABEL: add_i64_0x7ffef800:
493 ; LA64-NEXT: addu16i.d $a0, $a0, 32767
494 ; LA64-NEXT: addi.d $a0, $a0, -2048
496 %add = add i64 %x, 2147416064
500 define i64 @add_i64_minus_0x80000800(i64 %x) {
501 ; LA32-LABEL: add_i64_minus_0x80000800:
503 ; LA32-NEXT: lu12i.w $a2, 524287
504 ; LA32-NEXT: ori $a2, $a2, 2048
505 ; LA32-NEXT: add.w $a2, $a0, $a2
506 ; LA32-NEXT: sltu $a0, $a2, $a0
507 ; LA32-NEXT: add.w $a0, $a1, $a0
508 ; LA32-NEXT: addi.w $a1, $a0, -1
509 ; LA32-NEXT: move $a0, $a2
512 ; LA64-LABEL: add_i64_minus_0x80000800:
514 ; LA64-NEXT: addu16i.d $a0, $a0, -32768
515 ; LA64-NEXT: addi.d $a0, $a0, -2048
517 %add = add i64 %x, -2147485696
521 define i32 @add_i32_minus_0x23450679(i32 %x) {
522 ; LA32-LABEL: add_i32_minus_0x23450679:
524 ; LA32-NEXT: lu12i.w $a1, -144465
525 ; LA32-NEXT: ori $a1, $a1, 2439
526 ; LA32-NEXT: add.w $a0, $a0, $a1
529 ; LA64-LABEL: add_i32_minus_0x23450679:
531 ; LA64-NEXT: addu16i.d $a0, $a0, -9029
532 ; LA64-NEXT: addi.w $a0, $a0, -1657
534 %add = add i32 %x, -591726201
538 define signext i32 @add_i32_minus_0x23450679_sext(i32 %x) {
539 ; LA32-LABEL: add_i32_minus_0x23450679_sext:
541 ; LA32-NEXT: lu12i.w $a1, -144465
542 ; LA32-NEXT: ori $a1, $a1, 2439
543 ; LA32-NEXT: add.w $a0, $a0, $a1
546 ; LA64-LABEL: add_i32_minus_0x23450679_sext:
548 ; LA64-NEXT: addu16i.d $a0, $a0, -9029
549 ; LA64-NEXT: addi.w $a0, $a0, -1657
551 %add = add i32 %x, -591726201
555 define i64 @add_i64_minus_0x23450679(i64 %x) {
556 ; LA32-LABEL: add_i64_minus_0x23450679:
558 ; LA32-NEXT: lu12i.w $a2, -144465
559 ; LA32-NEXT: ori $a2, $a2, 2439
560 ; LA32-NEXT: add.w $a2, $a0, $a2
561 ; LA32-NEXT: sltu $a0, $a2, $a0
562 ; LA32-NEXT: add.w $a0, $a1, $a0
563 ; LA32-NEXT: addi.w $a1, $a0, -1
564 ; LA32-NEXT: move $a0, $a2
567 ; LA64-LABEL: add_i64_minus_0x23450679:
569 ; LA64-NEXT: addu16i.d $a0, $a0, -9029
570 ; LA64-NEXT: addi.d $a0, $a0, -1657
572 %add = add i64 %x, -591726201
576 define i32 @add_i32_minus_0x2345fedd(i32 %x) {
577 ; LA32-LABEL: add_i32_minus_0x2345fedd:
579 ; LA32-NEXT: lu12i.w $a1, -144480
580 ; LA32-NEXT: ori $a1, $a1, 291
581 ; LA32-NEXT: add.w $a0, $a0, $a1
584 ; LA64-LABEL: add_i32_minus_0x2345fedd:
586 ; LA64-NEXT: addu16i.d $a0, $a0, -9030
587 ; LA64-NEXT: addi.w $a0, $a0, 291
589 %add = add i32 %x, -591789789
593 define signext i32 @add_i32_minus_0x2345fedd_sext(i32 %x) {
594 ; LA32-LABEL: add_i32_minus_0x2345fedd_sext:
596 ; LA32-NEXT: lu12i.w $a1, -144480
597 ; LA32-NEXT: ori $a1, $a1, 291
598 ; LA32-NEXT: add.w $a0, $a0, $a1
601 ; LA64-LABEL: add_i32_minus_0x2345fedd_sext:
603 ; LA64-NEXT: addu16i.d $a0, $a0, -9030
604 ; LA64-NEXT: addi.w $a0, $a0, 291
606 %add = add i32 %x, -591789789
610 define i64 @add_i64_minus_0x2345fedd(i64 %x) {
611 ; LA32-LABEL: add_i64_minus_0x2345fedd:
613 ; LA32-NEXT: lu12i.w $a2, -144480
614 ; LA32-NEXT: ori $a2, $a2, 291
615 ; LA32-NEXT: add.w $a2, $a0, $a2
616 ; LA32-NEXT: sltu $a0, $a2, $a0
617 ; LA32-NEXT: add.w $a0, $a1, $a0
618 ; LA32-NEXT: addi.w $a1, $a0, -1
619 ; LA32-NEXT: move $a0, $a2
622 ; LA64-LABEL: add_i64_minus_0x2345fedd:
624 ; LA64-NEXT: addu16i.d $a0, $a0, -9030
625 ; LA64-NEXT: addi.d $a0, $a0, 291
627 %add = add i64 %x, -591789789
631 ;; Check that `addu16i.d` isn't used for the following cases.
633 define i64 @add_i64_0x80000000(i64 %x) {
634 ; LA32-LABEL: add_i64_0x80000000:
636 ; LA32-NEXT: lu12i.w $a2, -524288
637 ; LA32-NEXT: add.w $a2, $a0, $a2
638 ; LA32-NEXT: sltu $a0, $a2, $a0
639 ; LA32-NEXT: add.w $a1, $a1, $a0
640 ; LA32-NEXT: move $a0, $a2
643 ; LA64-LABEL: add_i64_0x80000000:
645 ; LA64-NEXT: lu12i.w $a1, -524288
646 ; LA64-NEXT: lu32i.d $a1, 0
647 ; LA64-NEXT: add.d $a0, $a0, $a1
649 %add = add i64 %x, 2147483648
653 define i64 @add_i64_0xffff0000(i64 %x) {
654 ; LA32-LABEL: add_i64_0xffff0000:
656 ; LA32-NEXT: lu12i.w $a2, -16
657 ; LA32-NEXT: add.w $a2, $a0, $a2
658 ; LA32-NEXT: sltu $a0, $a2, $a0
659 ; LA32-NEXT: add.w $a1, $a1, $a0
660 ; LA32-NEXT: move $a0, $a2
663 ; LA64-LABEL: add_i64_0xffff0000:
665 ; LA64-NEXT: lu12i.w $a1, -16
666 ; LA64-NEXT: lu32i.d $a1, 0
667 ; LA64-NEXT: add.d $a0, $a0, $a1
669 %add = add i64 %x, 4294901760
673 ;; -0x80000800 is equivalent to +0x7ffff800 in i32, so addu16i.d isn't matched
675 define i32 @add_i32_minus_0x80000800(i32 %x) {
676 ; LA32-LABEL: add_i32_minus_0x80000800:
678 ; LA32-NEXT: lu12i.w $a1, 524287
679 ; LA32-NEXT: ori $a1, $a1, 2048
680 ; LA32-NEXT: add.w $a0, $a0, $a1
683 ; LA64-LABEL: add_i32_minus_0x80000800:
685 ; LA64-NEXT: lu12i.w $a1, 524287
686 ; LA64-NEXT: ori $a1, $a1, 2048
687 ; LA64-NEXT: add.w $a0, $a0, $a1
689 %add = add i32 %x, -2147485696
693 define signext i32 @add_i32_minus_0x80000800_sext(i32 %x) {
694 ; LA32-LABEL: add_i32_minus_0x80000800_sext:
696 ; LA32-NEXT: lu12i.w $a1, 524287
697 ; LA32-NEXT: ori $a1, $a1, 2048
698 ; LA32-NEXT: add.w $a0, $a0, $a1
701 ; LA64-LABEL: add_i32_minus_0x80000800_sext:
703 ; LA64-NEXT: lu12i.w $a1, 524287
704 ; LA64-NEXT: ori $a1, $a1, 2048
705 ; LA64-NEXT: add.w $a0, $a0, $a1
707 %add = add i32 %x, -2147485696
711 define signext i32 @add_i32_4080(i32 %x) {
712 ; LA32-LABEL: add_i32_4080:
714 ; LA32-NEXT: addi.w $a0, $a0, 2047
715 ; LA32-NEXT: addi.w $a0, $a0, 2033
718 ; LA64-LABEL: add_i32_4080:
720 ; LA64-NEXT: addi.d $a0, $a0, 2047
721 ; LA64-NEXT: addi.w $a0, $a0, 2033
723 %add = add i32 %x, 4080
727 define signext i32 @add_i32_minus_4080(i32 %x) {
728 ; LA32-LABEL: add_i32_minus_4080:
730 ; LA32-NEXT: addi.w $a0, $a0, -2048
731 ; LA32-NEXT: addi.w $a0, $a0, -2032
734 ; LA64-LABEL: add_i32_minus_4080:
736 ; LA64-NEXT: addi.d $a0, $a0, -2048
737 ; LA64-NEXT: addi.w $a0, $a0, -2032
739 %add = add i32 %x, -4080
743 define signext i32 @add_i32_2048(i32 %x) {
744 ; LA32-LABEL: add_i32_2048:
746 ; LA32-NEXT: addi.w $a0, $a0, 2047
747 ; LA32-NEXT: addi.w $a0, $a0, 1
750 ; LA64-LABEL: add_i32_2048:
752 ; LA64-NEXT: addi.d $a0, $a0, 2047
753 ; LA64-NEXT: addi.w $a0, $a0, 1
755 %add = add i32 %x, 2048
759 define signext i32 @add_i32_4094(i32 %x) {
760 ; LA32-LABEL: add_i32_4094:
762 ; LA32-NEXT: addi.w $a0, $a0, 2047
763 ; LA32-NEXT: addi.w $a0, $a0, 2047
766 ; LA64-LABEL: add_i32_4094:
768 ; LA64-NEXT: addi.d $a0, $a0, 2047
769 ; LA64-NEXT: addi.w $a0, $a0, 2047
771 %add = add i32 %x, 4094
775 define signext i32 @add_i32_minus_2049(i32 %x) {
776 ; LA32-LABEL: add_i32_minus_2049:
778 ; LA32-NEXT: addi.w $a0, $a0, -2048
779 ; LA32-NEXT: addi.w $a0, $a0, -1
782 ; LA64-LABEL: add_i32_minus_2049:
784 ; LA64-NEXT: addi.d $a0, $a0, -2048
785 ; LA64-NEXT: addi.w $a0, $a0, -1
787 %add = add i32 %x, -2049
791 define signext i32 @add_i32_minus_4096(i32 %x) {
792 ; LA32-LABEL: add_i32_minus_4096:
794 ; LA32-NEXT: addi.w $a0, $a0, -2048
795 ; LA32-NEXT: addi.w $a0, $a0, -2048
798 ; LA64-LABEL: add_i32_minus_4096:
800 ; LA64-NEXT: addi.d $a0, $a0, -2048
801 ; LA64-NEXT: addi.w $a0, $a0, -2048
803 %add = add i32 %x, -4096
807 define i64 @add_i64_4080(i64 %x) {
808 ; LA32-LABEL: add_i64_4080:
810 ; LA32-NEXT: addi.w $a2, $a0, 2047
811 ; LA32-NEXT: addi.w $a2, $a2, 2033
812 ; LA32-NEXT: sltu $a0, $a2, $a0
813 ; LA32-NEXT: add.w $a1, $a1, $a0
814 ; LA32-NEXT: move $a0, $a2
817 ; LA64-LABEL: add_i64_4080:
819 ; LA64-NEXT: addi.d $a0, $a0, 2047
820 ; LA64-NEXT: addi.d $a0, $a0, 2033
822 %add = add i64 %x, 4080
826 define i64 @add_i64_minus_4080(i64 %x) {
827 ; LA32-LABEL: add_i64_minus_4080:
829 ; LA32-NEXT: addi.w $a2, $a0, -2048
830 ; LA32-NEXT: addi.w $a2, $a2, -2032
831 ; LA32-NEXT: sltu $a0, $a2, $a0
832 ; LA32-NEXT: add.w $a0, $a1, $a0
833 ; LA32-NEXT: addi.w $a1, $a0, -1
834 ; LA32-NEXT: move $a0, $a2
837 ; LA64-LABEL: add_i64_minus_4080:
839 ; LA64-NEXT: addi.d $a0, $a0, -2048
840 ; LA64-NEXT: addi.d $a0, $a0, -2032
842 %add = add i64 %x, -4080
846 define i64 @add_i64_2048(i64 %x) {
847 ; LA32-LABEL: add_i64_2048:
849 ; LA32-NEXT: addi.w $a2, $a0, 2047
850 ; LA32-NEXT: addi.w $a2, $a2, 1
851 ; LA32-NEXT: sltu $a0, $a2, $a0
852 ; LA32-NEXT: add.w $a1, $a1, $a0
853 ; LA32-NEXT: move $a0, $a2
856 ; LA64-LABEL: add_i64_2048:
858 ; LA64-NEXT: addi.d $a0, $a0, 2047
859 ; LA64-NEXT: addi.d $a0, $a0, 1
861 %add = add i64 %x, 2048
865 define i64 @add_i64_4094(i64 %x) {
866 ; LA32-LABEL: add_i64_4094:
868 ; LA32-NEXT: addi.w $a2, $a0, 2047
869 ; LA32-NEXT: addi.w $a2, $a2, 2047
870 ; LA32-NEXT: sltu $a0, $a2, $a0
871 ; LA32-NEXT: add.w $a1, $a1, $a0
872 ; LA32-NEXT: move $a0, $a2
875 ; LA64-LABEL: add_i64_4094:
877 ; LA64-NEXT: addi.d $a0, $a0, 2047
878 ; LA64-NEXT: addi.d $a0, $a0, 2047
880 %add = add i64 %x, 4094
884 define i64 @add_i64_minus_2049(i64 %x) {
885 ; LA32-LABEL: add_i64_minus_2049:
887 ; LA32-NEXT: addi.w $a2, $a0, -2048
888 ; LA32-NEXT: addi.w $a2, $a2, -1
889 ; LA32-NEXT: sltu $a0, $a2, $a0
890 ; LA32-NEXT: add.w $a0, $a1, $a0
891 ; LA32-NEXT: addi.w $a1, $a0, -1
892 ; LA32-NEXT: move $a0, $a2
895 ; LA64-LABEL: add_i64_minus_2049:
897 ; LA64-NEXT: addi.d $a0, $a0, -2048
898 ; LA64-NEXT: addi.d $a0, $a0, -1
900 %add = add i64 %x, -2049
904 define i64 @add_i64_minus_4096(i64 %x) {
905 ; LA32-LABEL: add_i64_minus_4096:
907 ; LA32-NEXT: addi.w $a2, $a0, -2048
908 ; LA32-NEXT: addi.w $a2, $a2, -2048
909 ; LA32-NEXT: sltu $a0, $a2, $a0
910 ; LA32-NEXT: add.w $a0, $a1, $a0
911 ; LA32-NEXT: addi.w $a1, $a0, -1
912 ; LA32-NEXT: move $a0, $a2
915 ; LA64-LABEL: add_i64_minus_4096:
917 ; LA64-NEXT: addi.d $a0, $a0, -2048
918 ; LA64-NEXT: addi.d $a0, $a0, -2048
920 %add = add i64 %x, -4096