1 # RUN: llc -O0 -mtriple arm-- -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
3 define void @test_mla() #0 { ret void }
4 define void @test_mla_commutative() #0 { ret void }
5 define void @test_mla_v5() #1 { ret void }
7 define void @test_mls() #2 { ret void }
8 define void @test_no_mls() { ret void }
10 define void @test_bicrr() { ret void }
11 define void @test_bicrr_commutative() { ret void }
13 define void @test_bicri() { ret void }
14 define void @test_bicri_commutative_xor() { ret void }
15 define void @test_bicri_commutative_and() { ret void }
16 define void @test_bicri_commutative_both() { ret void }
18 define void @test_movti16_0xffff() #2 { ret void }
20 define void @test_vnmuls() #3 { ret void }
21 define void @test_vnmuls_reassociate() #3 { ret void }
22 define void @test_vnmuld() #3 { ret void }
24 define void @test_vfnmas() #4 { ret void }
25 define void @test_vfnmad() #4 { ret void }
27 define void @test_vfmss() #4 { ret void }
28 define void @test_vfmsd() #4 { ret void }
30 define void @test_vfnmss() #4 { ret void }
32 define void @test_bfc() #2 { ret void }
33 define void @test_no_bfc_bad_mask() #2 { ret void }
35 attributes #0 = { "target-features"="+v6" }
36 attributes #1 = { "target-features"="-v6" }
37 attributes #2 = { "target-features"="+v6t2" }
38 attributes #3 = { "target-features"="+vfp2" }
39 attributes #4 = { "target-features"="+vfp4" }
43 # CHECK-LABEL: name: test_mla
47 # CHECK: selected: true
49 - { id: 0, class: gprb }
50 - { id: 1, class: gprb }
51 - { id: 2, class: gprb }
52 - { id: 3, class: gprb }
53 - { id: 4, class: gprb }
56 liveins: $r0, $r1, $r2
61 ; CHECK: [[VREGX:%[0-9]+]]:gprnopc = COPY $r0
62 ; CHECK: [[VREGY:%[0-9]+]]:gprnopc = COPY $r1
63 ; CHECK: [[VREGZ:%[0-9]+]]:gprnopc = COPY $r2
65 %3(s32) = G_MUL %0, %1
66 %4(s32) = G_ADD %3, %2
67 ; CHECK: [[VREGR:%[0-9]+]]:gprnopc = MLA [[VREGX]], [[VREGY]], [[VREGZ]], 14, $noreg, $noreg
70 ; CHECK: $r0 = COPY [[VREGR]]
72 BX_RET 14, $noreg, implicit $r0
73 ; CHECK: BX_RET 14, $noreg, implicit $r0
76 name: test_mla_commutative
77 # CHECK-LABEL: name: test_mla_commutative
81 # CHECK: selected: true
83 - { id: 0, class: gprb }
84 - { id: 1, class: gprb }
85 - { id: 2, class: gprb }
86 - { id: 3, class: gprb }
87 - { id: 4, class: gprb }
90 liveins: $r0, $r1, $r2
95 ; CHECK: [[VREGX:%[0-9]+]]:gprnopc = COPY $r0
96 ; CHECK: [[VREGY:%[0-9]+]]:gprnopc = COPY $r1
97 ; CHECK: [[VREGZ:%[0-9]+]]:gprnopc = COPY $r2
99 %3(s32) = G_MUL %0, %1
100 %4(s32) = G_ADD %2, %3
101 ; CHECK: [[VREGR:%[0-9]+]]:gprnopc = MLA [[VREGX]], [[VREGY]], [[VREGZ]], 14, $noreg, $noreg
104 ; CHECK: $r0 = COPY [[VREGR]]
106 BX_RET 14, $noreg, implicit $r0
107 ; CHECK: BX_RET 14, $noreg, implicit $r0
111 # CHECK-LABEL: name: test_mla_v5
113 regBankSelected: true
115 # CHECK: selected: true
117 - { id: 0, class: gprb }
118 - { id: 1, class: gprb }
119 - { id: 2, class: gprb }
120 - { id: 3, class: gprb }
121 - { id: 4, class: gprb }
124 liveins: $r0, $r1, $r2
129 ; CHECK: [[VREGX:%[0-9]+]]:gprnopc = COPY $r0
130 ; CHECK: [[VREGY:%[0-9]+]]:gprnopc = COPY $r1
131 ; CHECK: [[VREGZ:%[0-9]+]]:gprnopc = COPY $r2
133 %3(s32) = G_MUL %0, %1
134 %4(s32) = G_ADD %3, %2
135 ; CHECK: [[VREGR:%[0-9]+]]:gprnopc = MLAv5 [[VREGX]], [[VREGY]], [[VREGZ]], 14, $noreg, $noreg
138 ; CHECK: $r0 = COPY [[VREGR]]
140 BX_RET 14, $noreg, implicit $r0
141 ; CHECK: BX_RET 14, $noreg, implicit $r0
145 # CHECK-LABEL: name: test_mls
147 regBankSelected: true
149 # CHECK: selected: true
151 - { id: 0, class: gprb }
152 - { id: 1, class: gprb }
153 - { id: 2, class: gprb }
154 - { id: 3, class: gprb }
155 - { id: 4, class: gprb }
158 liveins: $r0, $r1, $r2
163 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
164 ; CHECK: [[VREGY:%[0-9]+]]:gpr = COPY $r1
165 ; CHECK: [[VREGZ:%[0-9]+]]:gpr = COPY $r2
167 %3(s32) = G_MUL %0, %1
168 %4(s32) = G_SUB %2, %3
169 ; CHECK: [[VREGR:%[0-9]+]]:gpr = MLS [[VREGX]], [[VREGY]], [[VREGZ]], 14, $noreg
172 ; CHECK: $r0 = COPY [[VREGR]]
174 BX_RET 14, $noreg, implicit $r0
175 ; CHECK: BX_RET 14, $noreg, implicit $r0
179 # CHECK-LABEL: name: test_no_mls
181 regBankSelected: true
183 # CHECK: selected: true
185 - { id: 0, class: gprb }
186 - { id: 1, class: gprb }
187 - { id: 2, class: gprb }
188 - { id: 3, class: gprb }
189 - { id: 4, class: gprb }
192 liveins: $r0, $r1, $r2
197 ; CHECK: [[VREGX:%[0-9]+]]:gprnopc = COPY $r0
198 ; CHECK: [[VREGY:%[0-9]+]]:gprnopc = COPY $r1
199 ; CHECK: [[VREGZ:%[0-9]+]]:gpr = COPY $r2
201 %3(s32) = G_MUL %0, %1
202 %4(s32) = G_SUB %2, %3
203 ; CHECK: [[VREGM:%[0-9]+]]:gprnopc = MULv5 [[VREGX]], [[VREGY]], 14, $noreg, $noreg
204 ; CHECK: [[VREGR:%[0-9]+]]:gpr = SUBrr [[VREGZ]], [[VREGM]], 14, $noreg, $noreg
207 ; CHECK: $r0 = COPY [[VREGR]]
209 BX_RET 14, $noreg, implicit $r0
210 ; CHECK: BX_RET 14, $noreg, implicit $r0
214 # CHECK-LABEL: name: test_bicrr
216 regBankSelected: true
218 # CHECK: selected: true
220 - { id: 0, class: gprb }
221 - { id: 1, class: gprb }
222 - { id: 2, class: gprb }
223 - { id: 3, class: gprb }
224 - { id: 4, class: gprb }
231 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
232 ; CHECK: [[VREGY:%[0-9]+]]:gpr = COPY $r1
234 %2(s32) = G_CONSTANT i32 -1
235 %3(s32) = G_XOR %1, %2
236 %4(s32) = G_AND %0, %3
237 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICrr [[VREGX]], [[VREGY]], 14, $noreg, $noreg
240 ; CHECK: $r0 = COPY [[VREGR]]
242 BX_RET 14, $noreg, implicit $r0
243 ; CHECK: BX_RET 14, $noreg, implicit $r0
246 name: test_bicrr_commutative
247 # CHECK-LABEL: name: test_bicrr_commutative
249 regBankSelected: true
251 # CHECK: selected: true
253 - { id: 0, class: gprb }
254 - { id: 1, class: gprb }
255 - { id: 2, class: gprb }
256 - { id: 3, class: gprb }
257 - { id: 4, class: gprb }
264 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
265 ; CHECK: [[VREGY:%[0-9]+]]:gpr = COPY $r1
267 %2(s32) = G_CONSTANT i32 -1
268 %3(s32) = G_XOR %1, %2
269 %4(s32) = G_AND %3, %0
270 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICrr [[VREGX]], [[VREGY]], 14, $noreg, $noreg
273 ; CHECK: $r0 = COPY [[VREGR]]
275 BX_RET 14, $noreg, implicit $r0
276 ; CHECK: BX_RET 14, $noreg, implicit $r0
280 # CHECK-LABEL: name: test_bicri
282 regBankSelected: true
284 # CHECK: selected: true
286 - { id: 0, class: gprb }
287 - { id: 1, class: gprb }
288 - { id: 2, class: gprb }
289 - { id: 3, class: gprb }
290 - { id: 4, class: gprb }
296 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
298 ; This test and the following ones are a bit contrived, since they use a
299 ; G_XOR that can be constant-folded. They exist mostly to validate the
300 ; TableGen pattern that defines BICri. We also have a pattern for matching a
301 ; G_AND with a G_CONSTANT operand directly, which is the more common case,
302 ; but that will be covered by different tests.
303 %1(s32) = G_CONSTANT i32 192
305 %2(s32) = G_CONSTANT i32 -1
306 %3(s32) = G_XOR %1, %2
307 %4(s32) = G_AND %0, %3
308 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICri [[VREGX]], 192, 14, $noreg, $noreg
311 ; CHECK: $r0 = COPY [[VREGR]]
313 BX_RET 14, $noreg, implicit $r0
314 ; CHECK: BX_RET 14, $noreg, implicit $r0
317 name: test_bicri_commutative_xor
318 # CHECK-LABEL: name: test_bicri_commutative_xor
320 regBankSelected: true
322 # CHECK: selected: true
324 - { id: 0, class: gprb }
325 - { id: 1, class: gprb }
326 - { id: 2, class: gprb }
327 - { id: 3, class: gprb }
328 - { id: 4, class: gprb }
334 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
336 %1(s32) = G_CONSTANT i32 192
338 %2(s32) = G_CONSTANT i32 -1
339 %3(s32) = G_XOR %2, %1
340 %4(s32) = G_AND %0, %3
341 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICri [[VREGX]], 192, 14, $noreg, $noreg
344 ; CHECK: $r0 = COPY [[VREGR]]
346 BX_RET 14, $noreg, implicit $r0
347 ; CHECK: BX_RET 14, $noreg, implicit $r0
350 name: test_bicri_commutative_and
351 # CHECK-LABEL: name: test_bicri_commutative_and
353 regBankSelected: true
355 # CHECK: selected: true
357 - { id: 0, class: gprb }
358 - { id: 1, class: gprb }
359 - { id: 2, class: gprb }
360 - { id: 3, class: gprb }
361 - { id: 4, class: gprb }
367 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
369 %1(s32) = G_CONSTANT i32 192
371 %2(s32) = G_CONSTANT i32 -1
372 %3(s32) = G_XOR %1, %2
373 %4(s32) = G_AND %3, %0
374 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICri [[VREGX]], 192, 14, $noreg, $noreg
377 ; CHECK: $r0 = COPY [[VREGR]]
379 BX_RET 14, $noreg, implicit $r0
380 ; CHECK: BX_RET 14, $noreg, implicit $r0
383 name: test_bicri_commutative_both
384 # CHECK-LABEL: name: test_bicri_commutative_both
386 regBankSelected: true
388 # CHECK: selected: true
390 - { id: 0, class: gprb }
391 - { id: 1, class: gprb }
392 - { id: 2, class: gprb }
393 - { id: 3, class: gprb }
394 - { id: 4, class: gprb }
400 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
402 %1(s32) = G_CONSTANT i32 192
404 %2(s32) = G_CONSTANT i32 -1
405 %3(s32) = G_XOR %2, %1
406 %4(s32) = G_AND %3, %0
407 ; CHECK: [[VREGR:%[0-9]+]]:gpr = BICri [[VREGX]], 192, 14, $noreg, $noreg
410 ; CHECK: $r0 = COPY [[VREGR]]
412 BX_RET 14, $noreg, implicit $r0
413 ; CHECK: BX_RET 14, $noreg, implicit $r0
416 name: test_movti16_0xffff
417 # CHECK-LABEL: name: test_movti16_0xffff
419 regBankSelected: true
421 # CHECK: selected: true
423 - { id: 0, class: gprb }
424 - { id: 1, class: gprb }
425 - { id: 2, class: gprb }
431 ; CHECK: [[VREGX:%[0-9]+]]:gpr = COPY $r0
433 %1(s32) = G_CONSTANT i32 4294901760 ; 0xFFFF0000
435 %2(s32) = G_OR %0, %1
436 ; CHECK: [[VREGR:%[0-9]+]]:gprnopc = MOVTi16 [[VREGX]], 65535, 14, $noreg
439 ; CHECK: $r0 = COPY [[VREGR]]
441 BX_RET 14, $noreg, implicit $r0
442 ; CHECK: BX_RET 14, $noreg, implicit $r0
446 # CHECK-LABEL: name: test_vnmuls
448 regBankSelected: true
450 # CHECK: selected: true
452 - { id: 0, class: fprb }
453 - { id: 1, class: fprb }
454 - { id: 2, class: fprb }
455 - { id: 3, class: fprb }
462 ; CHECK-DAG: [[VREGX:%[0-9]+]]:spr = COPY $s0
463 ; CHECK-DAG: [[VREGY:%[0-9]+]]:spr = COPY $s1
465 %2(s32) = G_FMUL %0, %1
467 ; CHECK: [[VREGR:%[0-9]+]]:spr = VNMULS [[VREGX]], [[VREGY]], 14, $noreg
470 ; CHECK: $s0 = COPY [[VREGR]]
472 BX_RET 14, $noreg, implicit $s0
473 ; CHECK: BX_RET 14, $noreg, implicit $s0
476 name: test_vnmuls_reassociate
477 # CHECK-LABEL: name: test_vnmuls_reassociate
479 regBankSelected: true
481 # CHECK: selected: true
483 - { id: 0, class: fprb }
484 - { id: 1, class: fprb }
485 - { id: 2, class: fprb }
486 - { id: 3, class: fprb }
493 ; CHECK-DAG: [[VREGX:%[0-9]+]]:spr = COPY $s0
494 ; CHECK-DAG: [[VREGY:%[0-9]+]]:spr = COPY $s1
497 %3(s32) = G_FMUL %1, %2
498 ; CHECK: [[VREGR:%[0-9]+]]:spr = VNMULS [[VREGX]], [[VREGY]], 14, $noreg
501 ; CHECK: $s0 = COPY [[VREGR]]
503 BX_RET 14, $noreg, implicit $s0
504 ; CHECK: BX_RET 14, $noreg, implicit $s0
508 # CHECK-LABEL: name: test_vnmuld
510 regBankSelected: true
512 # CHECK: selected: true
514 - { id: 0, class: fprb }
515 - { id: 1, class: fprb }
516 - { id: 2, class: fprb }
517 - { id: 3, class: fprb }
524 ; CHECK-DAG: [[VREGX:%[0-9]+]]:dpr = COPY $d0
525 ; CHECK-DAG: [[VREGY:%[0-9]+]]:dpr = COPY $d1
527 %2(s64) = G_FMUL %0, %1
529 ; CHECK: [[VREGR:%[0-9]+]]:dpr = VNMULD [[VREGX]], [[VREGY]], 14, $noreg
532 ; CHECK: $d0 = COPY [[VREGR]]
534 BX_RET 14, $noreg, implicit $d0
535 ; CHECK: BX_RET 14, $noreg, implicit $d0
539 # CHECK-LABEL: name: test_vfnmas
541 regBankSelected: true
543 # CHECK: selected: true
545 - { id: 0, class: fprb }
546 - { id: 1, class: fprb }
547 - { id: 2, class: fprb }
548 - { id: 3, class: fprb }
549 - { id: 4, class: fprb }
552 liveins: $s0, $s1, $s2
557 ; CHECK-DAG: [[VREGX:%[0-9]+]]:spr = COPY $s0
558 ; CHECK-DAG: [[VREGY:%[0-9]+]]:spr = COPY $s1
559 ; CHECK-DAG: [[VREGZ:%[0-9]+]]:spr = COPY $s2
561 %3(s32) = G_FMA %0, %1, %2
563 ; CHECK: [[VREGR:%[0-9]+]]:spr = VFNMAS [[VREGZ]], [[VREGX]], [[VREGY]], 14, $noreg
566 ; CHECK: $s0 = COPY [[VREGR]]
568 BX_RET 14, $noreg, implicit $s0
569 ; CHECK: BX_RET 14, $noreg, implicit $s0
573 # CHECK-LABEL: name: test_vfnmad
575 regBankSelected: true
577 # CHECK: selected: true
579 - { id: 0, class: fprb }
580 - { id: 1, class: fprb }
581 - { id: 2, class: fprb }
582 - { id: 3, class: fprb }
583 - { id: 4, class: fprb }
584 - { id: 5, class: fprb }
587 liveins: $d0, $d1, $d2
592 ; CHECK-DAG: [[VREGX:%[0-9]+]]:dpr = COPY $d0
593 ; CHECK-DAG: [[VREGY:%[0-9]+]]:dpr = COPY $d1
594 ; CHECK-DAG: [[VREGZ:%[0-9]+]]:dpr = COPY $d2
598 %5(s64) = G_FMA %3, %1, %4
599 ; CHECK: [[VREGR:%[0-9]+]]:dpr = VFNMAD [[VREGZ]], [[VREGX]], [[VREGY]], 14, $noreg
602 ; CHECK: $d0 = COPY [[VREGR]]
604 BX_RET 14, $noreg, implicit $d0
605 ; CHECK: BX_RET 14, $noreg, implicit $d0
609 # CHECK-LABEL: name: test_vfmss
611 regBankSelected: true
613 # CHECK: selected: true
615 - { id: 0, class: fprb }
616 - { id: 1, class: fprb }
617 - { id: 2, class: fprb }
618 - { id: 3, class: fprb }
619 - { id: 4, class: fprb }
622 liveins: $s0, $s1, $s2
627 ; CHECK-DAG: [[VREGX:%[0-9]+]]:spr = COPY $s0
628 ; CHECK-DAG: [[VREGY:%[0-9]+]]:spr = COPY $s1
629 ; CHECK-DAG: [[VREGZ:%[0-9]+]]:spr = COPY $s2
632 %4(s32) = G_FMA %3, %1, %2
633 ; CHECK: [[VREGR:%[0-9]+]]:spr = VFMSS [[VREGZ]], [[VREGX]], [[VREGY]], 14, $noreg
636 ; CHECK: $s0 = COPY [[VREGR]]
638 BX_RET 14, $noreg, implicit $s0
639 ; CHECK: BX_RET 14, $noreg, implicit $s0
643 # CHECK-LABEL: name: test_vfmsd
645 regBankSelected: true
647 # CHECK: selected: true
649 - { id: 0, class: fprb }
650 - { id: 1, class: fprb }
651 - { id: 2, class: fprb }
652 - { id: 3, class: fprb }
653 - { id: 4, class: fprb }
656 liveins: $d0, $d1, $d2
661 ; CHECK-DAG: [[VREGX:%[0-9]+]]:dpr = COPY $d0
662 ; CHECK-DAG: [[VREGY:%[0-9]+]]:dpr = COPY $d1
663 ; CHECK-DAG: [[VREGZ:%[0-9]+]]:dpr = COPY $d2
666 %4(s64) = G_FMA %0, %3, %2
667 ; CHECK: [[VREGR:%[0-9]+]]:dpr = VFMSD [[VREGZ]], [[VREGX]], [[VREGY]], 14, $noreg
670 ; CHECK: $d0 = COPY [[VREGR]]
672 BX_RET 14, $noreg, implicit $d0
673 ; CHECK: BX_RET 14, $noreg, implicit $d0
677 # CHECK-LABEL: name: test_vfnmss
679 regBankSelected: true
681 # CHECK: selected: true
683 - { id: 0, class: fprb }
684 - { id: 1, class: fprb }
685 - { id: 2, class: fprb }
686 - { id: 3, class: fprb }
687 - { id: 4, class: fprb }
690 liveins: $s0, $s1, $s2
695 ; CHECK-DAG: [[VREGX:%[0-9]+]]:spr = COPY $s0
696 ; CHECK-DAG: [[VREGY:%[0-9]+]]:spr = COPY $s1
697 ; CHECK-DAG: [[VREGZ:%[0-9]+]]:spr = COPY $s2
700 %4(s32) = G_FMA %0, %1, %3
701 ; CHECK: [[VREGR:%[0-9]+]]:spr = VFNMSS [[VREGZ]], [[VREGX]], [[VREGY]], 14, $noreg
704 ; CHECK: $s0 = COPY [[VREGR]]
706 BX_RET 14, $noreg, implicit $s0
707 ; CHECK: BX_RET 14, $noreg, implicit $s0
711 # CHECK-LABEL: name: test_bfc
713 regBankSelected: true
715 # CHECK: selected: true
717 - { id: 0, class: gprb }
718 - { id: 1, class: gprb }
719 - { id: 2, class: gprb }
725 %1(s32) = G_CONSTANT i32 -65529 ; 0xFFFF0007
726 %2(s32) = G_AND %0, %1
727 ; CHECK: [[RS:%[0-9]+]]:gpr = COPY $r0
728 ; CHECK: [[RD:%[0-9]+]]:gpr = BFC [[RS]], -65529, 14, $noreg
731 ; CHECK: $r0 = COPY [[RD]]
733 BX_RET 14, $noreg, implicit $r0
734 ; CHECK: BX_RET 14, $noreg, implicit $r0
737 name: test_no_bfc_bad_mask
738 # CHECK-LABEL: name: test_no_bfc_bad_mask
740 regBankSelected: true
742 # CHECK: selected: true
744 - { id: 0, class: gprb }
745 - { id: 1, class: gprb }
746 - { id: 2, class: gprb }
752 %1(s32) = G_CONSTANT i32 6 ; 0x00000006
753 %2(s32) = G_AND %0, %1
754 ; CHECK: [[RS:%[0-9]+]]:gpr = COPY $r0
758 ; CHECK: $r0 = COPY [[RD]]
760 BX_RET 14, $noreg, implicit $r0
761 ; CHECK: BX_RET 14, $noreg, implicit $r0