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 }
34 # CHECK-LABEL: name: test_add_s8
36 # CHECK: legalized: true
37 regBankSelected: false
39 tracksRegLiveness: true
52 %1(s8) = G_LOAD %0 :: (load 1)
54 %3(s8) = G_LOAD %2 :: (load 1)
56 ; G_ADD with s8 should widen
57 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_ADD {{%[0-9]+, %[0-9]+}}
58 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
59 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_ADD {{%[0-9]+, %[0-9]+}}
60 %5(s32) = G_SEXT %4(s8)
62 BX_RET 14, $noreg, implicit $r0
66 # CHECK-LABEL: name: test_add_s16
68 # CHECK: legalized: true
69 regBankSelected: false
71 tracksRegLiveness: true
84 %1(s16) = G_LOAD %0 :: (load 2)
86 %3(s16) = G_LOAD %2 :: (load 2)
87 %4(s16) = G_ADD %1, %3
88 ; G_ADD with s16 should widen
89 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_ADD {{%[0-9]+, %[0-9]+}}
90 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
91 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_ADD {{%[0-9]+, %[0-9]+}}
92 %5(s32) = G_SEXT %4(s16)
94 BX_RET 14, $noreg, implicit $r0
98 # CHECK-LABEL: name: test_add_s32
100 # CHECK: legalized: true
101 regBankSelected: false
103 tracksRegLiveness: true
105 - { id: 0, class: _ }
106 - { id: 1, class: _ }
107 - { id: 2, class: _ }
114 %2(s32) = G_ADD %0, %1
115 ; G_ADD with s32 is legal, so we should find it unchanged in the output
116 ; CHECK: {{%[0-9]+}}:_(s32) = G_ADD {{%[0-9]+, %[0-9]+}}
118 BX_RET 14, $noreg, implicit $r0
123 # CHECK-LABEL: name: test_sub_s8
125 # CHECK: legalized: true
126 regBankSelected: false
128 tracksRegLiveness: true
130 - { id: 0, class: _ }
131 - { id: 1, class: _ }
132 - { id: 2, class: _ }
133 - { id: 3, class: _ }
134 - { id: 4, class: _ }
135 - { id: 5, class: _ }
141 %1(s8) = G_LOAD %0 :: (load 1)
143 %3(s8) = G_LOAD %2 :: (load 1)
144 %4(s8) = G_SUB %1, %3
145 ; G_SUB with s8 should widen
146 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SUB {{%[0-9]+, %[0-9]+}}
147 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
148 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SUB {{%[0-9]+, %[0-9]+}}
149 %5(s32) = G_SEXT %4(s8)
151 BX_RET 14, $noreg, implicit $r0
155 # CHECK-LABEL: name: test_sub_s16
157 # CHECK: legalized: true
158 regBankSelected: false
160 tracksRegLiveness: true
162 - { id: 0, class: _ }
163 - { id: 1, class: _ }
164 - { id: 2, class: _ }
165 - { id: 3, class: _ }
166 - { id: 4, class: _ }
167 - { id: 5, class: _ }
173 %1(s16) = G_LOAD %0 :: (load 2)
175 %3(s16) = G_LOAD %2 :: (load 2)
176 %4(s16) = G_SUB %1, %3
177 ; G_SUB with s16 should widen
178 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SUB {{%[0-9]+, %[0-9]+}}
179 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
180 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SUB {{%[0-9]+, %[0-9]+}}
181 %5(s32) = G_SEXT %4(s16)
183 BX_RET 14, $noreg, implicit $r0
187 # CHECK-LABEL: name: test_sub_s32
189 # CHECK: legalized: true
190 regBankSelected: false
192 tracksRegLiveness: true
194 - { id: 0, class: _ }
195 - { id: 1, class: _ }
196 - { id: 2, class: _ }
203 %2(s32) = G_SUB %0, %1
204 ; G_SUB with s32 is legal, so we should find it unchanged in the output
205 ; CHECK: {{%[0-9]+}}:_(s32) = G_SUB {{%[0-9]+, %[0-9]+}}
207 BX_RET 14, $noreg, implicit $r0
212 # CHECK-LABEL: name: test_mul_s8
214 # CHECK: legalized: true
215 regBankSelected: false
217 tracksRegLiveness: true
219 - { id: 0, class: _ }
220 - { id: 1, class: _ }
221 - { id: 2, class: _ }
222 - { id: 3, class: _ }
223 - { id: 4, class: _ }
224 - { id: 5, class: _ }
230 %1(s8) = G_LOAD %0 :: (load 1)
232 %3(s8) = G_LOAD %2 :: (load 1)
233 %4(s8) = G_MUL %1, %3
234 ; G_MUL with s8 should widen
235 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_MUL {{%[0-9]+, %[0-9]+}}
236 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
237 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_MUL {{%[0-9]+, %[0-9]+}}
238 %5(s32) = G_SEXT %4(s8)
240 BX_RET 14, $noreg, implicit $r0
244 # CHECK-LABEL: name: test_mul_s16
246 # CHECK: legalized: true
247 regBankSelected: false
249 tracksRegLiveness: true
251 - { id: 0, class: _ }
252 - { id: 1, class: _ }
253 - { id: 2, class: _ }
254 - { id: 3, class: _ }
255 - { id: 4, class: _ }
256 - { id: 5, class: _ }
262 %1(s16) = G_LOAD %0 :: (load 2)
264 %3(s16) = G_LOAD %2 :: (load 2)
265 %4(s16) = G_MUL %1, %3
266 ; G_MUL with s16 should widen
267 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_MUL {{%[0-9]+, %[0-9]+}}
268 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
269 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_MUL {{%[0-9]+, %[0-9]+}}
270 %5(s32) = G_SEXT %4(s16)
272 BX_RET 14, $noreg, implicit $r0
276 # CHECK-LABEL: name: test_mul_s32
278 # CHECK: legalized: true
279 regBankSelected: false
281 tracksRegLiveness: true
283 - { id: 0, class: _ }
284 - { id: 1, class: _ }
285 - { id: 2, class: _ }
292 %2(s32) = G_MUL %0, %1
293 ; G_MUL with s32 is legal, so we should find it unchanged in the output
294 ; CHECK: {{%[0-9]+}}:_(s32) = G_MUL {{%[0-9]+, %[0-9]+}}
296 BX_RET 14, $noreg, implicit $r0
301 # CHECK-LABEL: name: test_and_s8
303 # CHECK: legalized: true
304 regBankSelected: false
306 tracksRegLiveness: true
308 - { id: 0, class: _ }
309 - { id: 1, class: _ }
310 - { id: 2, class: _ }
311 - { id: 3, class: _ }
312 - { id: 4, class: _ }
313 - { id: 5, class: _ }
319 %1(s8) = G_LOAD %0 :: (load 1)
321 %3(s8) = G_LOAD %2 :: (load 1)
322 %4(s8) = G_AND %1, %3
323 ; G_AND with s8 should widen
324 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_AND {{%[0-9]+, %[0-9]+}}
325 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
326 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_AND {{%[0-9]+, %[0-9]+}}
327 %5(s32) = G_SEXT %4(s8)
329 BX_RET 14, $noreg, implicit $r0
333 # CHECK-LABEL: name: test_and_s16
335 # CHECK: legalized: true
336 regBankSelected: false
338 tracksRegLiveness: true
340 - { id: 0, class: _ }
341 - { id: 1, class: _ }
342 - { id: 2, class: _ }
343 - { id: 3, class: _ }
344 - { id: 4, class: _ }
345 - { id: 5, class: _ }
351 %1(s16) = G_LOAD %0 :: (load 2)
353 %3(s16) = G_LOAD %2 :: (load 2)
354 %4(s16) = G_AND %1, %3
355 ; G_AND with s16 should widen
356 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_AND {{%[0-9]+, %[0-9]+}}
357 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
358 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_AND {{%[0-9]+, %[0-9]+}}
359 %5(s32) = G_SEXT %4(s16)
361 BX_RET 14, $noreg, implicit $r0
365 # CHECK-LABEL: name: test_and_s32
367 # CHECK: legalized: true
368 regBankSelected: false
370 tracksRegLiveness: true
372 - { id: 0, class: _ }
373 - { id: 1, class: _ }
374 - { id: 2, class: _ }
381 %2(s32) = G_AND %0, %1
382 ; G_AND with s32 is legal, so we should find it unchanged in the output
383 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND {{%[0-9]+, %[0-9]+}}
385 BX_RET 14, $noreg, implicit $r0
390 # CHECK-LABEL: name: test_or_s8
392 # CHECK: legalized: true
393 regBankSelected: false
395 tracksRegLiveness: true
397 - { id: 0, class: _ }
398 - { id: 1, class: _ }
399 - { id: 2, class: _ }
400 - { id: 3, class: _ }
401 - { id: 4, class: _ }
402 - { id: 5, class: _ }
408 %1(s8) = G_LOAD %0 :: (load 1)
410 %3(s8) = G_LOAD %2 :: (load 1)
412 ; G_OR with s8 should widen
413 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_OR {{%[0-9]+, %[0-9]+}}
414 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
415 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_OR {{%[0-9]+, %[0-9]+}}
416 %5(s32) = G_SEXT %4(s8)
418 BX_RET 14, $noreg, implicit $r0
422 # CHECK-LABEL: name: test_or_s16
424 # CHECK: legalized: true
425 regBankSelected: false
427 tracksRegLiveness: true
429 - { id: 0, class: _ }
430 - { id: 1, class: _ }
431 - { id: 2, class: _ }
432 - { id: 3, class: _ }
433 - { id: 4, class: _ }
434 - { id: 5, class: _ }
440 %1(s16) = G_LOAD %0 :: (load 2)
442 %3(s16) = G_LOAD %2 :: (load 2)
443 %4(s16) = G_OR %1, %3
444 ; G_OR with s16 should widen
445 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_OR {{%[0-9]+, %[0-9]+}}
446 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
447 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_OR {{%[0-9]+, %[0-9]+}}
448 %5(s32) = G_SEXT %4(s16)
450 BX_RET 14, $noreg, implicit $r0
454 # CHECK-LABEL: name: test_or_s32
456 # CHECK: legalized: true
457 regBankSelected: false
459 tracksRegLiveness: true
461 - { id: 0, class: _ }
462 - { id: 1, class: _ }
463 - { id: 2, class: _ }
470 %2(s32) = G_OR %0, %1
471 ; G_OR with s32 is legal, so we should find it unchanged in the output
472 ; CHECK: {{%[0-9]+}}:_(s32) = G_OR {{%[0-9]+, %[0-9]+}}
474 BX_RET 14, $noreg, implicit $r0
479 # CHECK-LABEL: name: test_xor_s8
481 # CHECK: legalized: true
482 regBankSelected: false
484 tracksRegLiveness: true
486 - { id: 0, class: _ }
487 - { id: 1, class: _ }
488 - { id: 2, class: _ }
489 - { id: 3, class: _ }
490 - { id: 4, class: _ }
491 - { id: 5, class: _ }
497 %1(s8) = G_LOAD %0 :: (load 1)
499 %3(s8) = G_LOAD %2 :: (load 1)
500 %4(s8) = G_XOR %1, %3
501 ; G_XOR with s8 should widen
502 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_XOR {{%[0-9]+, %[0-9]+}}
503 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
504 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_XOR {{%[0-9]+, %[0-9]+}}
505 %5(s32) = G_SEXT %4(s8)
507 BX_RET 14, $noreg, implicit $r0
511 # CHECK-LABEL: name: test_xor_s16
513 # CHECK: legalized: true
514 regBankSelected: false
516 tracksRegLiveness: true
518 - { id: 0, class: _ }
519 - { id: 1, class: _ }
520 - { id: 2, class: _ }
521 - { id: 3, class: _ }
522 - { id: 4, class: _ }
523 - { id: 5, class: _ }
529 %1(s16) = G_LOAD %0 :: (load 2)
531 %3(s16) = G_LOAD %2 :: (load 2)
532 %4(s16) = G_XOR %1, %3
533 ; G_XOR with s16 should widen
534 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_XOR {{%[0-9]+, %[0-9]+}}
535 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
536 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_XOR {{%[0-9]+, %[0-9]+}}
537 %5(s32) = G_SEXT %4(s16)
539 BX_RET 14, $noreg, implicit $r0
543 # CHECK-LABEL: name: test_xor_s32
545 # CHECK: legalized: true
546 regBankSelected: false
548 tracksRegLiveness: true
550 - { id: 0, class: _ }
551 - { id: 1, class: _ }
552 - { id: 2, class: _ }
559 %2(s32) = G_XOR %0, %1
560 ; G_XOR with s32 is legal, so we should find it unchanged in the output
561 ; CHECK: {{%[0-9]+}}:_(s32) = G_XOR {{%[0-9]+, %[0-9]+}}
563 BX_RET 14, $noreg, implicit $r0
568 # CHECK-LABEL: name: test_lshr_s32
570 # CHECK: legalized: true
571 regBankSelected: false
573 tracksRegLiveness: true
575 - { id: 0, class: _ }
576 - { id: 1, class: _ }
577 - { id: 2, class: _ }
584 %2(s32) = G_LSHR %0, %1
585 ; G_LSHR with s32 is legal, so we should find it unchanged in the output
586 ; CHECK: {{%[0-9]+}}:_(s32) = G_LSHR {{%[0-9]+, %[0-9]+}}
588 BX_RET 14, $noreg, implicit $r0
593 # CHECK-LABEL: name: test_ashr_s32
595 # CHECK: legalized: true
596 regBankSelected: false
598 tracksRegLiveness: true
600 - { id: 0, class: _ }
601 - { id: 1, class: _ }
602 - { id: 2, class: _ }
609 %2(s32) = G_ASHR %0, %1
610 ; G_ASHR with s32 is legal, so we should find it unchanged in the output
611 ; CHECK: {{%[0-9]+}}:_(s32) = G_ASHR {{%[0-9]+, %[0-9]+}}
613 BX_RET 14, $noreg, implicit $r0
618 # CHECK-LABEL: name: test_shl_s32
620 # CHECK: legalized: true
621 regBankSelected: false
623 tracksRegLiveness: true
625 - { id: 0, class: _ }
626 - { id: 1, class: _ }
627 - { id: 2, class: _ }
634 %2(s32) = G_SHL %0, %1
635 ; G_SHL with s32 is legal, so we should find it unchanged in the output
636 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
638 BX_RET 14, $noreg, implicit $r0