1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=mips64-mti-linux-gnu %s -o - -start-before mips-delay-slot-filler -stop-after mips-branch-expansion | FileCheck %s --check-prefix=MIPS64
3 # RUN: llc -mtriple=mips64-mti-linux-gnu %s -o - -start-before mips-delay-slot-filler -stop-after mips-branch-expansion -relocation-model=pic | FileCheck %s --check-prefix=PIC
5 # Test the long branch expansion of various branches
8 define i64 @expand_BEQ64(i64 %a, i64 %b) {
9 %cmp = icmp eq i64 %a, %b
10 br i1 %cmp, label %iftrue, label %tail
13 call void asm sideeffect ".space 131068", ""()
20 define i64 @expand_BNE64(i64 %a, i64 %b) {
21 %cmp = icmp eq i64 %a, %b
22 br i1 %cmp, label %iftrue, label %tail
25 call void asm sideeffect ".space 131068", ""()
32 define i64 @expand_BGEZ64(i64 %a, i64 %b) {
33 %cmp = icmp eq i64 %a, %b
34 br i1 %cmp, label %iftrue, label %tail
37 call void asm sideeffect ".space 131068", ""()
44 define i64 @expand_BGTZ64(i64 %a, i64 %b) {
45 %cmp = icmp eq i64 %a, %b
46 br i1 %cmp, label %iftrue, label %tail
49 call void asm sideeffect ".space 131068", ""()
56 define i64 @expand_BLEZ64(i64 %a, i64 %b) {
57 %cmp = icmp eq i64 %a, %b
58 br i1 %cmp, label %iftrue, label %tail
61 call void asm sideeffect ".space 131068", ""()
68 define i64 @expand_BLTZ64(i64 %a, i64 %b) {
69 %cmp = icmp eq i64 %a, %b
70 br i1 %cmp, label %iftrue, label %tail
73 call void asm sideeffect ".space 131068", ""()
85 exposesReturnsTwice: false
87 regBankSelected: false
90 tracksRegLiveness: true
93 - { reg: '$a0_64', virtual-reg: '' }
95 isFrameAddressTaken: false
96 isReturnAddressTaken: false
106 hasOpaqueSPAdjustment: false
108 hasMustTailInVarArgFunc: false
116 ; MIPS64-LABEL: name: expand_BEQ64
117 ; MIPS64: bb.0 (%ir-block.0):
118 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
119 ; MIPS64: BNE64 $a0_64, $zero_64, %bb.2, implicit-def $at {
122 ; MIPS64: bb.1 (%ir-block.0):
123 ; MIPS64: successors: %bb.3(0x80000000)
124 ; MIPS64: J %bb.3, implicit-def $at {
127 ; MIPS64: bb.2.iftrue:
128 ; MIPS64: INLINEASM &".space 131068", 1
129 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
130 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
133 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
134 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
136 ; PIC-LABEL: name: expand_BEQ64
137 ; PIC: bb.0 (%ir-block.0):
138 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
139 ; PIC: BNE64 $a0_64, $zero_64, %bb.3, implicit-def $at {
142 ; PIC: bb.1 (%ir-block.0):
143 ; PIC: successors: %bb.2(0x80000000)
144 ; PIC: $sp_64 = DADDiu $sp_64, -16
145 ; PIC: SD $ra_64, $sp_64, 0
146 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
147 ; PIC: $at_64 = DSLL $at_64, 16
148 ; PIC: BAL_BR %bb.2, implicit-def $ra {
149 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
151 ; PIC: bb.2 (%ir-block.0):
152 ; PIC: successors: %bb.4(0x80000000)
153 ; PIC: $at_64 = DADDu $ra_64, $at_64
154 ; PIC: $ra_64 = LD $sp_64, 0
156 ; PIC: $sp_64 = DADDiu $sp_64, 16
159 ; PIC: INLINEASM &".space 131068", 1
160 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
161 ; PIC: $v0_64 = DADDiu $zero_64, 1
164 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
165 ; PIC: $v0_64 = DADDiu $zero_64, 0
168 successors: %bb.1(0x40000000), %bb.2(0x40000000)
171 BEQ64 killed renamable $a0_64, $zero_64, %bb.2, implicit-def $at
174 INLINEASM &".space 131068", 1
175 $v0_64 = DADDiu $zero_64, 1
176 PseudoReturn64 undef $ra_64, implicit killed $v0_64
179 $v0_64 = DADDiu $zero_64, 0
180 PseudoReturn64 undef $ra_64, implicit killed $v0_64
187 exposesReturnsTwice: false
189 regBankSelected: false
192 tracksRegLiveness: true
195 - { reg: '$a0_64', virtual-reg: '' }
197 isFrameAddressTaken: false
198 isReturnAddressTaken: false
208 hasOpaqueSPAdjustment: false
210 hasMustTailInVarArgFunc: false
218 ; MIPS64-LABEL: name: expand_BNE64
219 ; MIPS64: bb.0 (%ir-block.0):
220 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
221 ; MIPS64: BEQ64 $a0_64, $zero_64, %bb.2, implicit-def $at {
224 ; MIPS64: bb.1 (%ir-block.0):
225 ; MIPS64: successors: %bb.3(0x80000000)
226 ; MIPS64: J %bb.3, implicit-def $at {
229 ; MIPS64: bb.2.iftrue:
230 ; MIPS64: INLINEASM &".space 131068", 1
231 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
232 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
235 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
236 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
238 ; PIC-LABEL: name: expand_BNE64
239 ; PIC: bb.0 (%ir-block.0):
240 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
241 ; PIC: BEQ64 $a0_64, $zero_64, %bb.3, implicit-def $at {
244 ; PIC: bb.1 (%ir-block.0):
245 ; PIC: successors: %bb.2(0x80000000)
246 ; PIC: $sp_64 = DADDiu $sp_64, -16
247 ; PIC: SD $ra_64, $sp_64, 0
248 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
249 ; PIC: $at_64 = DSLL $at_64, 16
250 ; PIC: BAL_BR %bb.2, implicit-def $ra {
251 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
253 ; PIC: bb.2 (%ir-block.0):
254 ; PIC: successors: %bb.4(0x80000000)
255 ; PIC: $at_64 = DADDu $ra_64, $at_64
256 ; PIC: $ra_64 = LD $sp_64, 0
258 ; PIC: $sp_64 = DADDiu $sp_64, 16
261 ; PIC: INLINEASM &".space 131068", 1
262 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
263 ; PIC: $v0_64 = DADDiu $zero_64, 1
266 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
267 ; PIC: $v0_64 = DADDiu $zero_64, 0
270 successors: %bb.1(0x40000000), %bb.2(0x40000000)
273 BNE64 killed renamable $a0_64, $zero_64, %bb.2, implicit-def $at
276 INLINEASM &".space 131068", 1
277 $v0_64 = DADDiu $zero_64, 1
278 PseudoReturn64 undef $ra_64, implicit killed $v0_64
281 $v0_64 = DADDiu $zero_64, 0
282 PseudoReturn64 undef $ra_64, implicit killed $v0_64
289 exposesReturnsTwice: false
291 regBankSelected: false
294 tracksRegLiveness: true
297 - { reg: '$a0_64', virtual-reg: '' }
299 isFrameAddressTaken: false
300 isReturnAddressTaken: false
310 hasOpaqueSPAdjustment: false
312 hasMustTailInVarArgFunc: false
320 ; MIPS64-LABEL: name: expand_BGEZ64
321 ; MIPS64: bb.0 (%ir-block.0):
322 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
323 ; MIPS64: BLTZ64 $a0_64, %bb.2, implicit-def $at {
326 ; MIPS64: bb.1 (%ir-block.0):
327 ; MIPS64: successors: %bb.3(0x80000000)
328 ; MIPS64: J %bb.3, implicit-def $at {
331 ; MIPS64: bb.2.iftrue:
332 ; MIPS64: INLINEASM &".space 131068", 1
333 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
334 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
337 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
338 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
340 ; PIC-LABEL: name: expand_BGEZ64
341 ; PIC: bb.0 (%ir-block.0):
342 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
343 ; PIC: BLTZ64 $a0_64, %bb.3, implicit-def $at {
346 ; PIC: bb.1 (%ir-block.0):
347 ; PIC: successors: %bb.2(0x80000000)
348 ; PIC: $sp_64 = DADDiu $sp_64, -16
349 ; PIC: SD $ra_64, $sp_64, 0
350 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
351 ; PIC: $at_64 = DSLL $at_64, 16
352 ; PIC: BAL_BR %bb.2, implicit-def $ra {
353 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
355 ; PIC: bb.2 (%ir-block.0):
356 ; PIC: successors: %bb.4(0x80000000)
357 ; PIC: $at_64 = DADDu $ra_64, $at_64
358 ; PIC: $ra_64 = LD $sp_64, 0
360 ; PIC: $sp_64 = DADDiu $sp_64, 16
363 ; PIC: INLINEASM &".space 131068", 1
364 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
365 ; PIC: $v0_64 = DADDiu $zero_64, 1
368 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
369 ; PIC: $v0_64 = DADDiu $zero_64, 0
372 successors: %bb.1(0x40000000), %bb.2(0x40000000)
375 BGEZ64 killed renamable $a0_64, %bb.2, implicit-def $at
378 INLINEASM &".space 131068", 1
379 $v0_64 = DADDiu $zero_64, 1
380 PseudoReturn64 undef $ra_64, implicit killed $v0_64
383 $v0_64 = DADDiu $zero_64, 0
384 PseudoReturn64 undef $ra_64, implicit killed $v0_64
391 exposesReturnsTwice: false
393 regBankSelected: false
396 tracksRegLiveness: true
399 - { reg: '$a0_64', virtual-reg: '' }
401 isFrameAddressTaken: false
402 isReturnAddressTaken: false
412 hasOpaqueSPAdjustment: false
414 hasMustTailInVarArgFunc: false
422 ; MIPS64-LABEL: name: expand_BGTZ64
423 ; MIPS64: bb.0 (%ir-block.0):
424 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
425 ; MIPS64: BLEZ64 $a0_64, %bb.2, implicit-def $at {
428 ; MIPS64: bb.1 (%ir-block.0):
429 ; MIPS64: successors: %bb.3(0x80000000)
430 ; MIPS64: J %bb.3, implicit-def $at {
433 ; MIPS64: bb.2.iftrue:
434 ; MIPS64: INLINEASM &".space 131068", 1
435 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
436 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
439 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
440 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
442 ; PIC-LABEL: name: expand_BGTZ64
443 ; PIC: bb.0 (%ir-block.0):
444 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
445 ; PIC: BLEZ64 $a0_64, %bb.3, implicit-def $at {
448 ; PIC: bb.1 (%ir-block.0):
449 ; PIC: successors: %bb.2(0x80000000)
450 ; PIC: $sp_64 = DADDiu $sp_64, -16
451 ; PIC: SD $ra_64, $sp_64, 0
452 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
453 ; PIC: $at_64 = DSLL $at_64, 16
454 ; PIC: BAL_BR %bb.2, implicit-def $ra {
455 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
457 ; PIC: bb.2 (%ir-block.0):
458 ; PIC: successors: %bb.4(0x80000000)
459 ; PIC: $at_64 = DADDu $ra_64, $at_64
460 ; PIC: $ra_64 = LD $sp_64, 0
462 ; PIC: $sp_64 = DADDiu $sp_64, 16
465 ; PIC: INLINEASM &".space 131068", 1
466 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
467 ; PIC: $v0_64 = DADDiu $zero_64, 1
470 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
471 ; PIC: $v0_64 = DADDiu $zero_64, 0
474 successors: %bb.1(0x40000000), %bb.2(0x40000000)
477 BGTZ64 killed renamable $a0_64, %bb.2, implicit-def $at
480 INLINEASM &".space 131068", 1
481 $v0_64 = DADDiu $zero_64, 1
482 PseudoReturn64 undef $ra_64, implicit killed $v0_64
485 $v0_64 = DADDiu $zero_64, 0
486 PseudoReturn64 undef $ra_64, implicit killed $v0_64
493 exposesReturnsTwice: false
495 regBankSelected: false
498 tracksRegLiveness: true
501 - { reg: '$a0_64', virtual-reg: '' }
503 isFrameAddressTaken: false
504 isReturnAddressTaken: false
514 hasOpaqueSPAdjustment: false
516 hasMustTailInVarArgFunc: false
524 ; MIPS64-LABEL: name: expand_BLEZ64
525 ; MIPS64: bb.0 (%ir-block.0):
526 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
527 ; MIPS64: BGTZ64 $a0_64, %bb.2, implicit-def $at {
530 ; MIPS64: bb.1 (%ir-block.0):
531 ; MIPS64: successors: %bb.3(0x80000000)
532 ; MIPS64: J %bb.3, implicit-def $at {
535 ; MIPS64: bb.2.iftrue:
536 ; MIPS64: INLINEASM &".space 131068", 1
537 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
538 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
541 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
542 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
544 ; PIC-LABEL: name: expand_BLEZ64
545 ; PIC: bb.0 (%ir-block.0):
546 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
547 ; PIC: BGTZ64 $a0_64, %bb.3, implicit-def $at {
550 ; PIC: bb.1 (%ir-block.0):
551 ; PIC: successors: %bb.2(0x80000000)
552 ; PIC: $sp_64 = DADDiu $sp_64, -16
553 ; PIC: SD $ra_64, $sp_64, 0
554 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
555 ; PIC: $at_64 = DSLL $at_64, 16
556 ; PIC: BAL_BR %bb.2, implicit-def $ra {
557 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
559 ; PIC: bb.2 (%ir-block.0):
560 ; PIC: successors: %bb.4(0x80000000)
561 ; PIC: $at_64 = DADDu $ra_64, $at_64
562 ; PIC: $ra_64 = LD $sp_64, 0
564 ; PIC: $sp_64 = DADDiu $sp_64, 16
567 ; PIC: INLINEASM &".space 131068", 1
568 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
569 ; PIC: $v0_64 = DADDiu $zero_64, 1
572 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
573 ; PIC: $v0_64 = DADDiu $zero_64, 0
576 successors: %bb.1(0x40000000), %bb.2(0x40000000)
579 BLEZ64 killed renamable $a0_64, %bb.2, implicit-def $at
582 INLINEASM &".space 131068", 1
583 $v0_64 = DADDiu $zero_64, 1
584 PseudoReturn64 undef $ra_64, implicit killed $v0_64
587 $v0_64 = DADDiu $zero_64, 0
588 PseudoReturn64 undef $ra_64, implicit killed $v0_64
595 exposesReturnsTwice: false
597 regBankSelected: false
600 tracksRegLiveness: true
603 - { reg: '$a0_64', virtual-reg: '' }
605 isFrameAddressTaken: false
606 isReturnAddressTaken: false
616 hasOpaqueSPAdjustment: false
618 hasMustTailInVarArgFunc: false
626 ; MIPS64-LABEL: name: expand_BLTZ64
627 ; MIPS64: bb.0 (%ir-block.0):
628 ; MIPS64: successors: %bb.2(0x40000000), %bb.1(0x40000000)
629 ; MIPS64: BGEZ64 $a0_64, %bb.2, implicit-def $at {
632 ; MIPS64: bb.1 (%ir-block.0):
633 ; MIPS64: successors: %bb.3(0x80000000)
634 ; MIPS64: J %bb.3, implicit-def $at {
637 ; MIPS64: bb.2.iftrue:
638 ; MIPS64: INLINEASM &".space 131068", 1
639 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
640 ; MIPS64: $v0_64 = DADDiu $zero_64, 1
643 ; MIPS64: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
644 ; MIPS64: $v0_64 = DADDiu $zero_64, 0
646 ; PIC-LABEL: name: expand_BLTZ64
647 ; PIC: bb.0 (%ir-block.0):
648 ; PIC: successors: %bb.3(0x40000000), %bb.1(0x40000000)
649 ; PIC: BGEZ64 $a0_64, %bb.3, implicit-def $at {
652 ; PIC: bb.1 (%ir-block.0):
653 ; PIC: successors: %bb.2(0x80000000)
654 ; PIC: $sp_64 = DADDiu $sp_64, -16
655 ; PIC: SD $ra_64, $sp_64, 0
656 ; PIC: $at_64 = LONG_BRANCH_DADDiu $zero_64, target-flags(mips-abs-hi) %bb.4, %bb.2
657 ; PIC: $at_64 = DSLL $at_64, 16
658 ; PIC: BAL_BR %bb.2, implicit-def $ra {
659 ; PIC: $at_64 = LONG_BRANCH_DADDiu $at_64, target-flags(mips-abs-lo) %bb.4, %bb.2
661 ; PIC: bb.2 (%ir-block.0):
662 ; PIC: successors: %bb.4(0x80000000)
663 ; PIC: $at_64 = DADDu $ra_64, $at_64
664 ; PIC: $ra_64 = LD $sp_64, 0
666 ; PIC: $sp_64 = DADDiu $sp_64, 16
669 ; PIC: INLINEASM &".space 131068", 1
670 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
671 ; PIC: $v0_64 = DADDiu $zero_64, 1
674 ; PIC: PseudoReturn64 undef $ra_64, implicit killed $v0_64 {
675 ; PIC: $v0_64 = DADDiu $zero_64, 0
678 successors: %bb.1(0x40000000), %bb.2(0x40000000)
681 BLTZ64 killed renamable $a0_64, %bb.2, implicit-def $at
684 INLINEASM &".space 131068", 1
685 $v0_64 = DADDiu $zero_64, 1
686 PseudoReturn64 undef $ra_64, implicit killed $v0_64
689 $v0_64 = DADDiu $zero_64, 0
690 PseudoReturn64 undef $ra_64, implicit killed $v0_64