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_zext_s16_to_s32() { ret void }
5 define void @test_sext_s8_to_s32() { ret void }
6 define void @test_sext_inreg_s8_to_s32() { ret void }
7 define void @test_anyext_s1_to_s32() { ret void }
9 define void @test_zext_s8_to_s16() { ret void }
10 define void @test_sext_s1_to_s16() { ret void }
12 define void @test_anyext_s1_to_s8() { ret void }
14 define void @test_ext_combine() { ret void }
17 name: test_zext_s16_to_s32
18 # CHECK-LABEL: name: test_zext_s16_to_s32
20 # CHECK: legalized: true
21 regBankSelected: false
23 tracksRegLiveness: true
33 %1(s16) = G_LOAD %0 :: (load (s16))
35 ; G_ZEXT with s16 is legal, so we should find it unchanged in the output
36 ; CHECK: {{%[0-9]+}}:_(s32) = G_ZEXT {{%[0-9]+}}
38 BX_RET 14, $noreg, implicit $r0
41 name: test_sext_s8_to_s32
42 # CHECK-LABEL: name: test_sext_s8_to_s32
44 # CHECK: legalized: true
45 regBankSelected: false
47 tracksRegLiveness: true
57 %1(s8) = G_LOAD %0(p0) :: (load (s8))
59 ; G_SEXT with s8 is legal, so we should find it unchanged in the output
60 ; CHECK: {{%[0-9]+}}:_(s32) = G_SEXT {{%[0-9]+}}
62 BX_RET 14, $noreg, implicit $r0
65 name: test_sext_inreg_s8_to_s32
66 # CHECK-LABEL: name: test_sext_inreg_s8_to_s32
68 # CHECK: legalized: true
69 regBankSelected: false
71 tracksRegLiveness: true
81 %1(s32) = G_LOAD %0(p0) :: (load (s32))
82 %2(s32) = G_SEXT_INREG %1, 8
83 ; G_SEXT_INREG should be lowered to a shift pair
84 ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
85 ; CHECK: [[T2:%[0-9]+]]:_(s32) = G_SHL {{%[0-9]+}}, [[T1]]
86 ; CHECK: {{%[0-9]+}}:_(s32) = G_ASHR [[T2]], [[T1]]
88 BX_RET 14, $noreg, implicit $r0
91 name: test_anyext_s1_to_s32
92 # CHECK-LABEL: name: test_anyext_s1_to_s32
94 # CHECK: legalized: true
95 regBankSelected: false
97 tracksRegLiveness: true
100 - { id: 1, class: _ }
101 - { id: 2, class: _ }
107 %1(s1) = G_LOAD %0(p0) :: (load (s1))
108 %2(s32) = G_ANYEXT %1
109 ; G_ANYEXT with s1 is legal, so we should find it unchanged in the output
110 ; CHECK: {{%[0-9]+}}:_(s32) = G_ANYEXT {{%[0-9]+}}
112 BX_RET 14, $noreg, implicit $r0
115 name: test_zext_s8_to_s16
116 # CHECK-LABEL: name: test_zext_s8_to_s16
118 # CHECK: legalized: true
119 regBankSelected: false
121 tracksRegLiveness: true
123 - { id: 0, class: _ }
124 - { id: 1, class: _ }
125 - { id: 2, class: _ }
131 %1(s8) = G_LOAD %0(p0) :: (load (s8))
133 ; G_ZEXT from s8 to s16 is legal, so we should find it unchanged in the output
134 ; CHECK: {{%[0-9]+}}:_(s16) = G_ZEXT {{%[0-9]+}}(s8)
135 G_STORE %2(s16), %0(p0) :: (store (s16))
139 name: test_sext_s1_to_s16
140 # CHECK-LABEL: name: test_sext_s1_to_s16
142 # CHECK: legalized: true
143 regBankSelected: false
145 tracksRegLiveness: true
152 %2:_(s32) = G_CONSTANT i32 0
153 %3:_(s1) = G_ICMP intpred(eq), %1, %2
154 %4:_(s16) = G_SEXT %3(s1)
155 ; G_SEXT from s1 to s16 is legal, so we should find it unchanged in the output
156 ; CHECK: {{%[0-9]+}}:_(s16) = G_SEXT {{%[0-9]+}}(s1)
157 G_STORE %4(s16), %0(p0) :: (store (s16))
161 name: test_anyext_s1_to_s8
162 # CHECK-LABEL: name: test_anyext_s1_to_s8
164 # CHECK: legalized: true
165 regBankSelected: false
167 tracksRegLiveness: true
174 %2:_(s32) = G_CONSTANT i32 0
175 %3:_(s1) = G_ICMP intpred(eq), %1, %2
176 %4:_(s8) = G_ANYEXT %3
177 ; G_ANYEXT from s1 to s8 is legal, so we should find it unchanged in the output
178 ; CHECK: {{%[0-9]+}}:_(s8) = G_ANYEXT {{%[0-9]+}}(s1)
179 G_STORE %4(s8), %0(p0) :: (store (s8))
183 name: test_ext_combine
184 # CHECK-LABEL: name: test_ext_combine
186 # CHECK: legalized: true
187 regBankSelected: false
189 tracksRegLiveness: true
191 - { id: 0, class: _ }
192 - { id: 1, class: _ }
193 - { id: 2, class: _ }
194 - { id: 3, class: _ }
195 - { id: 4, class: _ }
196 - { id: 5, class: _ }
202 %1(s8) = G_LOAD %0(p0) :: (load (s8))
203 ; CHECK: [[V8:%[0-9]+]]:_(s8) = G_LOAD
208 %4(s16) = G_OR %2, %3
209 ; G_OR is going to widen to 32 bits and the extensions/truncs should combine
210 ; with the already existing ones
211 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[V8]](s8)
212 ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[V8]](s8)
213 ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[ZEXT]], [[SEXT]]
214 ; CHECK: $r0 = COPY [[OR]]
216 %5(s32) = G_SEXT %4(s16)
219 BX_RET 14, $noreg, implicit $r0