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 2)
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 1)
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 4)
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 1)
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 1)
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 2)
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
147 - { id: 0, class: _ }
148 - { id: 1, class: _ }
149 - { id: 2, class: _ }
155 %1(s1) = G_LOAD %0(p0) :: (load 1)
156 %2(s16) = G_SEXT %1(s1)
157 ; G_SEXT from s1 to s16 is legal, so we should find it unchanged in the output
158 ; CHECK: {{%[0-9]+}}:_(s16) = G_SEXT {{%[0-9]+}}(s1)
159 G_STORE %2(s16), %0(p0) :: (store 2)
163 name: test_anyext_s1_to_s8
164 # CHECK-LABEL: name: test_anyext_s1_to_s8
166 # CHECK: legalized: true
167 regBankSelected: false
169 tracksRegLiveness: true
171 - { id: 0, class: _ }
172 - { id: 1, class: _ }
173 - { id: 2, class: _ }
179 %1(s1) = G_LOAD %0(p0) :: (load 1)
181 ; G_ANYEXT from s1 to s8 is legal, so we should find it unchanged in the output
182 ; CHECK: {{%[0-9]+}}:_(s8) = G_ANYEXT {{%[0-9]+}}(s1)
183 G_STORE %2(s8), %0(p0) :: (store 1)
187 name: test_ext_combine
188 # CHECK-LABEL: name: test_ext_combine
190 # CHECK: legalized: true
191 regBankSelected: false
193 tracksRegLiveness: true
195 - { id: 0, class: _ }
196 - { id: 1, class: _ }
197 - { id: 2, class: _ }
198 - { id: 3, class: _ }
199 - { id: 4, class: _ }
200 - { id: 5, class: _ }
206 %1(s8) = G_LOAD %0(p0) :: (load 1)
207 ; CHECK: [[V8:%[0-9]+]]:_(s8) = G_LOAD
212 %4(s16) = G_OR %2, %3
213 ; G_OR is going to widen to 32 bits and the extensions/truncs should combine
214 ; with the already existing ones
215 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[V8]](s8)
216 ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[V8]](s8)
217 ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[ZEXT]], [[SEXT]]
218 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[OR]]
219 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
220 ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[BITS]](s32)
221 ; CHECK: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[SHL]], [[BITS]](s32)
222 ; CHECK: $r0 = COPY [[ASHR]]
224 %5(s32) = G_SEXT %4(s16)
227 BX_RET 14, $noreg, implicit $r0