1 # RUN: llc -mtriple arm-- -run-pass=legalizer %s -o - | FileCheck %s
2 # RUN: llc -mtriple thumb-- -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s
4 define void @test_add_s8() { ret void }
5 define void @test_add_s16() { ret void }
6 define void @test_add_s32() { ret void }
8 define void @test_sub_s8() { ret void }
9 define void @test_sub_s16() { ret void }
10 define void @test_sub_s32() { ret void }
12 define void @test_mul_s8() { ret void }
13 define void @test_mul_s16() { ret void }
14 define void @test_mul_s32() { ret void }
16 define void @test_and_s8() { ret void }
17 define void @test_and_s16() { ret void }
18 define void @test_and_s32() { ret void }
20 define void @test_or_s8() { ret void }
21 define void @test_or_s16() { ret void }
22 define void @test_or_s32() { ret void }
24 define void @test_xor_s8() { ret void }
25 define void @test_xor_s16() { ret void }
26 define void @test_xor_s32() { ret void }
28 define void @test_lshr_s32() { ret void }
29 define void @test_ashr_s32() { ret void }
30 define void @test_shl_s32() { ret void }
32 define void @test_shift_s8() { ret void }
33 define void @test_shift_s16() { ret void }
34 define void @test_shift_amount_s8() { ret void }
35 define void @test_shift_amount_s16() { ret void }
39 # CHECK-LABEL: name: test_add_s8
41 # CHECK: legalized: true
42 regBankSelected: false
44 tracksRegLiveness: true
57 %1(s8) = G_LOAD %0 :: (load 1)
59 %3(s8) = G_LOAD %2 :: (load 1)
61 ; G_ADD with s8 should widen
62 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_ADD {{%[0-9]+, %[0-9]+}}
63 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
64 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_ADD {{%[0-9]+, %[0-9]+}}
65 %5(s32) = G_SEXT %4(s8)
67 BX_RET 14, $noreg, implicit $r0
71 # CHECK-LABEL: name: test_add_s16
73 # CHECK: legalized: true
74 regBankSelected: false
76 tracksRegLiveness: true
89 %1(s16) = G_LOAD %0 :: (load 2)
91 %3(s16) = G_LOAD %2 :: (load 2)
92 %4(s16) = G_ADD %1, %3
93 ; G_ADD with s16 should widen
94 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_ADD {{%[0-9]+, %[0-9]+}}
95 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
96 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_ADD {{%[0-9]+, %[0-9]+}}
97 %5(s32) = G_SEXT %4(s16)
99 BX_RET 14, $noreg, implicit $r0
103 # CHECK-LABEL: name: test_add_s32
105 # CHECK: legalized: true
106 regBankSelected: false
108 tracksRegLiveness: true
110 - { id: 0, class: _ }
111 - { id: 1, class: _ }
112 - { id: 2, class: _ }
119 %2(s32) = G_ADD %0, %1
120 ; G_ADD with s32 is legal, so we should find it unchanged in the output
121 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
123 BX_RET 14, $noreg, implicit $r0
128 # CHECK-LABEL: name: test_sub_s8
130 # CHECK: legalized: true
131 regBankSelected: false
133 tracksRegLiveness: true
135 - { id: 0, class: _ }
136 - { id: 1, class: _ }
137 - { id: 2, class: _ }
138 - { id: 3, class: _ }
139 - { id: 4, class: _ }
140 - { id: 5, class: _ }
146 %1(s8) = G_LOAD %0 :: (load 1)
148 %3(s8) = G_LOAD %2 :: (load 1)
149 %4(s8) = G_SUB %1, %3
150 ; G_SUB with s8 should widen
151 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SUB {{%[0-9]+, %[0-9]+}}
152 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
153 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SUB {{%[0-9]+, %[0-9]+}}
154 %5(s32) = G_SEXT %4(s8)
156 BX_RET 14, $noreg, implicit $r0
160 # CHECK-LABEL: name: test_sub_s16
162 # CHECK: legalized: true
163 regBankSelected: false
165 tracksRegLiveness: true
167 - { id: 0, class: _ }
168 - { id: 1, class: _ }
169 - { id: 2, class: _ }
170 - { id: 3, class: _ }
171 - { id: 4, class: _ }
172 - { id: 5, class: _ }
178 %1(s16) = G_LOAD %0 :: (load 2)
180 %3(s16) = G_LOAD %2 :: (load 2)
181 %4(s16) = G_SUB %1, %3
182 ; G_SUB with s16 should widen
183 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SUB {{%[0-9]+, %[0-9]+}}
184 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
185 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SUB {{%[0-9]+, %[0-9]+}}
186 %5(s32) = G_SEXT %4(s16)
188 BX_RET 14, $noreg, implicit $r0
192 # CHECK-LABEL: name: test_sub_s32
194 # CHECK: legalized: true
195 regBankSelected: false
197 tracksRegLiveness: true
199 - { id: 0, class: _ }
200 - { id: 1, class: _ }
201 - { id: 2, class: _ }
208 %2(s32) = G_SUB %0, %1
209 ; G_SUB with s32 is legal, so we should find it unchanged in the output
210 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
212 BX_RET 14, $noreg, implicit $r0
217 # CHECK-LABEL: name: test_mul_s8
219 # CHECK: legalized: true
220 regBankSelected: false
222 tracksRegLiveness: true
224 - { id: 0, class: _ }
225 - { id: 1, class: _ }
226 - { id: 2, class: _ }
227 - { id: 3, class: _ }
228 - { id: 4, class: _ }
229 - { id: 5, class: _ }
235 %1(s8) = G_LOAD %0 :: (load 1)
237 %3(s8) = G_LOAD %2 :: (load 1)
238 %4(s8) = G_MUL %1, %3
239 ; G_MUL with s8 should widen
240 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_MUL {{%[0-9]+, %[0-9]+}}
241 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
242 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_MUL {{%[0-9]+, %[0-9]+}}
243 %5(s32) = G_SEXT %4(s8)
245 BX_RET 14, $noreg, implicit $r0
249 # CHECK-LABEL: name: test_mul_s16
251 # CHECK: legalized: true
252 regBankSelected: false
254 tracksRegLiveness: true
256 - { id: 0, class: _ }
257 - { id: 1, class: _ }
258 - { id: 2, class: _ }
259 - { id: 3, class: _ }
260 - { id: 4, class: _ }
261 - { id: 5, class: _ }
267 %1(s16) = G_LOAD %0 :: (load 2)
269 %3(s16) = G_LOAD %2 :: (load 2)
270 %4(s16) = G_MUL %1, %3
271 ; G_MUL with s16 should widen
272 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_MUL {{%[0-9]+, %[0-9]+}}
273 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
274 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_MUL {{%[0-9]+, %[0-9]+}}
275 %5(s32) = G_SEXT %4(s16)
277 BX_RET 14, $noreg, implicit $r0
281 # CHECK-LABEL: name: test_mul_s32
283 # CHECK: legalized: true
284 regBankSelected: false
286 tracksRegLiveness: true
288 - { id: 0, class: _ }
289 - { id: 1, class: _ }
290 - { id: 2, class: _ }
297 %2(s32) = G_MUL %0, %1
298 ; G_MUL with s32 is legal, so we should find it unchanged in the output
299 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
301 BX_RET 14, $noreg, implicit $r0
306 # CHECK-LABEL: name: test_and_s8
308 # CHECK: legalized: true
309 regBankSelected: false
311 tracksRegLiveness: true
313 - { id: 0, class: _ }
314 - { id: 1, class: _ }
315 - { id: 2, class: _ }
316 - { id: 3, class: _ }
317 - { id: 4, class: _ }
318 - { id: 5, class: _ }
324 %1(s8) = G_LOAD %0 :: (load 1)
326 %3(s8) = G_LOAD %2 :: (load 1)
327 %4(s8) = G_AND %1, %3
328 ; G_AND with s8 should widen
329 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_AND {{%[0-9]+, %[0-9]+}}
330 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
331 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_AND {{%[0-9]+, %[0-9]+}}
332 %5(s32) = G_SEXT %4(s8)
334 BX_RET 14, $noreg, implicit $r0
338 # CHECK-LABEL: name: test_and_s16
340 # CHECK: legalized: true
341 regBankSelected: false
343 tracksRegLiveness: true
345 - { id: 0, class: _ }
346 - { id: 1, class: _ }
347 - { id: 2, class: _ }
348 - { id: 3, class: _ }
349 - { id: 4, class: _ }
350 - { id: 5, class: _ }
356 %1(s16) = G_LOAD %0 :: (load 2)
358 %3(s16) = G_LOAD %2 :: (load 2)
359 %4(s16) = G_AND %1, %3
360 ; G_AND with s16 should widen
361 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_AND {{%[0-9]+, %[0-9]+}}
362 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
363 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_AND {{%[0-9]+, %[0-9]+}}
364 %5(s32) = G_SEXT %4(s16)
366 BX_RET 14, $noreg, implicit $r0
370 # CHECK-LABEL: name: test_and_s32
372 # CHECK: legalized: true
373 regBankSelected: false
375 tracksRegLiveness: true
377 - { id: 0, class: _ }
378 - { id: 1, class: _ }
379 - { id: 2, class: _ }
386 %2(s32) = G_AND %0, %1
387 ; G_AND with s32 is legal, so we should find it unchanged in the output
388 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
390 BX_RET 14, $noreg, implicit $r0
395 # CHECK-LABEL: name: test_or_s8
397 # CHECK: legalized: true
398 regBankSelected: false
400 tracksRegLiveness: true
402 - { id: 0, class: _ }
403 - { id: 1, class: _ }
404 - { id: 2, class: _ }
405 - { id: 3, class: _ }
406 - { id: 4, class: _ }
407 - { id: 5, class: _ }
413 %1(s8) = G_LOAD %0 :: (load 1)
415 %3(s8) = G_LOAD %2 :: (load 1)
417 ; G_OR with s8 should widen
418 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_OR {{%[0-9]+, %[0-9]+}}
419 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
420 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_OR {{%[0-9]+, %[0-9]+}}
421 %5(s32) = G_SEXT %4(s8)
423 BX_RET 14, $noreg, implicit $r0
427 # CHECK-LABEL: name: test_or_s16
429 # CHECK: legalized: true
430 regBankSelected: false
432 tracksRegLiveness: true
434 - { id: 0, class: _ }
435 - { id: 1, class: _ }
436 - { id: 2, class: _ }
437 - { id: 3, class: _ }
438 - { id: 4, class: _ }
439 - { id: 5, class: _ }
445 %1(s16) = G_LOAD %0 :: (load 2)
447 %3(s16) = G_LOAD %2 :: (load 2)
448 %4(s16) = G_OR %1, %3
449 ; G_OR with s16 should widen
450 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_OR {{%[0-9]+, %[0-9]+}}
451 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
452 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_OR {{%[0-9]+, %[0-9]+}}
453 %5(s32) = G_SEXT %4(s16)
455 BX_RET 14, $noreg, implicit $r0
459 # CHECK-LABEL: name: test_or_s32
461 # CHECK: legalized: true
462 regBankSelected: false
464 tracksRegLiveness: true
466 - { id: 0, class: _ }
467 - { id: 1, class: _ }
468 - { id: 2, class: _ }
475 %2(s32) = G_OR %0, %1
476 ; G_OR with s32 is legal, so we should find it unchanged in the output
477 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
479 BX_RET 14, $noreg, implicit $r0
484 # CHECK-LABEL: name: test_xor_s8
486 # CHECK: legalized: true
487 regBankSelected: false
489 tracksRegLiveness: true
491 - { id: 0, class: _ }
492 - { id: 1, class: _ }
493 - { id: 2, class: _ }
494 - { id: 3, class: _ }
495 - { id: 4, class: _ }
496 - { id: 5, class: _ }
502 %1(s8) = G_LOAD %0 :: (load 1)
504 %3(s8) = G_LOAD %2 :: (load 1)
505 %4(s8) = G_XOR %1, %3
506 ; G_XOR with s8 should widen
507 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_XOR {{%[0-9]+, %[0-9]+}}
508 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
509 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_XOR {{%[0-9]+, %[0-9]+}}
510 %5(s32) = G_SEXT %4(s8)
512 BX_RET 14, $noreg, implicit $r0
516 # CHECK-LABEL: name: test_xor_s16
518 # CHECK: legalized: true
519 regBankSelected: false
521 tracksRegLiveness: true
523 - { id: 0, class: _ }
524 - { id: 1, class: _ }
525 - { id: 2, class: _ }
526 - { id: 3, class: _ }
527 - { id: 4, class: _ }
528 - { id: 5, class: _ }
534 %1(s16) = G_LOAD %0 :: (load 2)
536 %3(s16) = G_LOAD %2 :: (load 2)
537 %4(s16) = G_XOR %1, %3
538 ; G_XOR with s16 should widen
539 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_XOR {{%[0-9]+, %[0-9]+}}
540 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
541 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_XOR {{%[0-9]+, %[0-9]+}}
542 %5(s32) = G_SEXT %4(s16)
544 BX_RET 14, $noreg, implicit $r0
548 # CHECK-LABEL: name: test_xor_s32
550 # CHECK: legalized: true
551 regBankSelected: false
553 tracksRegLiveness: true
555 - { id: 0, class: _ }
556 - { id: 1, class: _ }
557 - { id: 2, class: _ }
564 %2(s32) = G_XOR %0, %1
565 ; G_XOR with s32 is legal, so we should find it unchanged in the output
566 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
568 BX_RET 14, $noreg, implicit $r0
573 # CHECK-LABEL: name: test_lshr_s32
575 # CHECK: legalized: true
576 regBankSelected: false
578 tracksRegLiveness: true
580 - { id: 0, class: _ }
581 - { id: 1, class: _ }
582 - { id: 2, class: _ }
589 %2(s32) = G_LSHR %0, %1
590 ; G_LSHR with s32 is legal, so we should find it unchanged in the output
591 ; CHECK: {{%[0-9]+}}:_(s32) = G_LSHR {{%[0-9]+, %[0-9]+}}
593 BX_RET 14, $noreg, implicit $r0
598 # CHECK-LABEL: name: test_ashr_s32
600 # CHECK: legalized: true
601 regBankSelected: false
603 tracksRegLiveness: true
605 - { id: 0, class: _ }
606 - { id: 1, class: _ }
607 - { id: 2, class: _ }
614 %2(s32) = G_ASHR %0, %1
615 ; G_ASHR with s32 is legal, so we should find it unchanged in the output
616 ; CHECK: {{%[0-9]+}}:_(s32) = G_ASHR {{%[0-9]+, %[0-9]+}}
618 BX_RET 14, $noreg, implicit $r0
623 # CHECK-LABEL: name: test_shl_s32
625 # CHECK: legalized: true
626 regBankSelected: false
628 tracksRegLiveness: true
630 - { id: 0, class: _ }
631 - { id: 1, class: _ }
632 - { id: 2, class: _ }
639 %2(s32) = G_SHL %0, %1
640 ; G_SHL with s32 is legal, so we should find it unchanged in the output
641 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
643 BX_RET 14, $noreg, implicit $r0
648 # CHECK-LABEL: name: test_shift_s8
650 # CHECK: legalized: true
651 regBankSelected: false
653 tracksRegLiveness: true
655 - { id: 0, class: _ }
656 - { id: 1, class: _ }
657 - { id: 2, class: _ }
658 - { id: 3, class: _ }
659 - { id: 4, class: _ }
666 %2(s8) = G_TRUNC %0(s32)
667 %3(s8) = G_SHL %2, %1(s32)
668 ; G_SHL with s8 should widen
669 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SHL {{%[0-9]+, %[0-9]+}}
670 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
671 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SHL {{%[0-9]+, %[0-9]+}}
672 %4(s32) = G_SEXT %3(s8)
674 BX_RET 14, $noreg, implicit $r0
678 # CHECK-LABEL: name: test_shift_s16
680 # CHECK: legalized: true
681 regBankSelected: false
683 tracksRegLiveness: true
685 - { id: 0, class: _ }
686 - { id: 1, class: _ }
687 - { id: 2, class: _ }
688 - { id: 3, class: _ }
689 - { id: 4, class: _ }
696 %2(s16) = G_TRUNC %0(s32)
697 %3(s16) = G_SHL %2, %1(s32)
698 ; G_SHL with s16 should widen
699 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SHL {{%[0-9]+, %[0-9]+}}
700 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
701 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SHL {{%[0-9]+, %[0-9]+}}
702 %4(s32) = G_SEXT %3(s16)
704 BX_RET 14, $noreg, implicit $r0
707 name: test_shift_amount_s8
708 # CHECK-LABEL: name: test_shift_amount_s8
710 # CHECK: legalized: true
711 regBankSelected: false
713 tracksRegLiveness: true
715 - { id: 0, class: _ }
716 - { id: 1, class: _ }
717 - { id: 2, class: _ }
718 - { id: 3, class: _ }
725 %2(s8) = G_TRUNC %0(s32)
726 %3(s32) = G_SHL %1, %2(s8)
727 ; G_SHL with s8 amount should widen
728 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s8)
729 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s32)
730 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s8)
732 BX_RET 14, $noreg, implicit $r0
735 name: test_shift_amount_s16
736 # CHECK-LABEL: name: test_shift_amount_s16
738 # CHECK: legalized: true
739 regBankSelected: false
741 tracksRegLiveness: true
743 - { id: 0, class: _ }
744 - { id: 1, class: _ }
745 - { id: 2, class: _ }
746 - { id: 3, class: _ }
753 %2(s16) = G_TRUNC %0(s32)
754 %3(s32) = G_SHL %1, %2(s16)
755 ; G_SHL with s16 amount should widen
756 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s16)
757 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s32)
758 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s16)
760 BX_RET 14, $noreg, implicit $r0