xref: /llvm-project/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-cmp.mir (revision fae05692a36f9ebbd201d93c2a6b0f927564d7e6)
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
3--- |
4  define void @test_icmp_s8() { ret void }
5  define void @test_icmp_s16() { ret void }
6  define void @test_icmp_s32() { ret void }
7
8  define void @test_icmp_p0() { ret void }
9...
10---
11name:            test_icmp_s8
12# CHECK-LABEL: name: test_icmp_s8
13legalized:       false
14# CHECK: legalized: true
15regBankSelected: false
16selected:        false
17tracksRegLiveness: true
18registers:
19  - { id: 0, class: _ }
20  - { id: 1, class: _ }
21  - { id: 2, class: _ }
22  - { id: 3, class: _ }
23  - { id: 4, class: _ }
24  - { id: 5, class: _ }
25body:             |
26  bb.0:
27    liveins: $r0, $r1
28
29    %0(p0) = COPY $r0
30    %1(s8) = G_LOAD %0 :: (load (s8))
31    %2(p0) = COPY $r1
32    %3(s8) = G_LOAD %2 :: (load (s8))
33    %4(s1) = G_ICMP intpred(ne), %1(s8), %3
34    ; G_ICMP with s8 should widen
35    ; CHECK: {{%[0-9]+}}:_(s1) = G_ICMP intpred(ne), {{%[0-9]+}}(s32), {{%[0-9]+}}
36    ; CHECK-NOT: {{%[0-9]+}}:_(s1) = G_ICMP intpred(ne), {{%[0-9]+}}(s8), {{%[0-9]+}}
37    %5(s32) = G_ZEXT %4(s1)
38    $r0 = COPY %5(s32)
39    BX_RET 14, $noreg, implicit $r0
40...
41---
42name:            test_icmp_s16
43# CHECK-LABEL: name: test_icmp_s16
44legalized:       false
45# CHECK: legalized: true
46regBankSelected: false
47selected:        false
48tracksRegLiveness: true
49registers:
50  - { id: 0, class: _ }
51  - { id: 1, class: _ }
52  - { id: 2, class: _ }
53  - { id: 3, class: _ }
54  - { id: 4, class: _ }
55  - { id: 5, class: _ }
56body:             |
57  bb.0:
58    liveins: $r0, $r1
59
60    %0(p0) = COPY $r0
61    %1(s16) = G_LOAD %0 :: (load (s16))
62    %2(p0) = COPY $r1
63    %3(s16) = G_LOAD %2 :: (load (s16))
64    %4(s1) = G_ICMP intpred(slt), %1(s16), %3
65    ; G_ICMP with s16 should widen
66    ; CHECK: {{%[0-9]+}}:_(s1) = G_ICMP intpred(slt), {{%[0-9]+}}(s32), {{%[0-9]+}}
67    ; CHECK-NOT: {{%[0-9]+}}:_(s1) = G_ICMP intpred(slt), {{%[0-9]+}}(s16), {{%[0-9]+}}
68    %5(s32) = G_ZEXT %4(s1)
69    $r0 = COPY %5(s32)
70    BX_RET 14, $noreg, implicit $r0
71...
72---
73name:            test_icmp_s32
74# CHECK-LABEL: name: test_icmp_s32
75legalized:       false
76# CHECK: legalized: true
77regBankSelected: false
78selected:        false
79tracksRegLiveness: true
80registers:
81  - { id: 0, class: _ }
82  - { id: 1, class: _ }
83  - { id: 2, class: _ }
84  - { id: 3, class: _ }
85body:             |
86  bb.0:
87    liveins: $r0, $r1
88
89    %0(s32) = COPY $r0
90    %1(s32) = COPY $r1
91    %2(s1) = G_ICMP intpred(eq), %0(s32), %1
92    ; G_ICMP with s32 is legal, so we should find it unchanged in the output
93    ; CHECK: {{%[0-9]+}}:_(s1) = G_ICMP intpred(eq), {{%[0-9]+}}(s32), {{%[0-9]+}}
94    %3(s32) = G_ZEXT %2(s1)
95    $r0 = COPY %3(s32)
96    BX_RET 14, $noreg, implicit $r0
97...
98---
99name:            test_icmp_p0
100# CHECK-LABEL: name: test_icmp_p0
101legalized:       false
102# CHECK: legalized: true
103regBankSelected: false
104selected:        false
105tracksRegLiveness: true
106registers:
107  - { id: 0, class: _ }
108  - { id: 1, class: _ }
109  - { id: 2, class: _ }
110  - { id: 3, class: _ }
111body:             |
112  bb.0:
113    liveins: $r0, $r1
114
115    %0(p0) = COPY $r0
116    %1(p0) = COPY $r1
117    %2(s1) = G_ICMP intpred(eq), %0(p0), %1
118    ; G_ICMP with p0 is legal, so we should find it unchanged in the output
119    ; CHECK: {{%[0-9]+}}:_(s1) = G_ICMP intpred(eq), {{%[0-9]+}}(p0), {{%[0-9]+}}
120    %3(s32) = G_ZEXT %2(s1)
121    $r0 = COPY %3(s32)
122    BX_RET 14, $noreg, implicit $r0
123...
124