1 # RUN: llc -mtriple arm-- -run-pass=legalizer %s -o - | FileCheck %s
3 define void @test_load_from_stack() { ret void }
4 define void @test_load_store_64() #0 { ret void }
6 define void @test_constants_s64() { ret void }
9 define void @test_phi_s32() { ret void }
10 define void @test_phi_p0() { ret void }
11 define void @test_phi_s64() #0 { ret void }
12 define void @test_phi_s8() { ret void }
14 @a_global = global i32 42
15 define void @test_global_variable() { ret void }
17 attributes #0 = { "target-features"="+vfp2" }
20 name: test_load_from_stack
21 # CHECK-LABEL: name: test_load_from_stack
23 # CHECK: legalized: true
24 regBankSelected: false
26 tracksRegLiveness: true
33 - { id: 0, offset: 0, size: 4, alignment: 4, isImmutable: true, isAliased: false }
34 - { id: 1, offset: 4, size: 4, alignment: 4, isImmutable: true, isAliased: false }
35 - { id: 2, offset: 8, size: 4, alignment: 4, isImmutable: true, isAliased: false }
36 # CHECK: id: [[FRAME_INDEX:[0-9]+]], type: default, offset: 8
39 liveins: $r0, $r1, $r2, $r3
41 ; This is legal, so we should find it unchanged in the output
42 ; CHECK: [[FIVREG:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[FRAME_INDEX]]
43 ; CHECK: {{%[0-9]+}}:_(s32) = G_LOAD [[FIVREG]](p0) :: (load 4)
44 %0(p0) = G_FRAME_INDEX %fixed-stack.2
45 %1(s32) = G_LOAD %0(p0) :: (load 4)
47 BX_RET 14, $noreg, implicit $r0
50 name: test_load_store_64
51 # CHECK-LABEL: name: test_load_store_64
53 # CHECK: legalized: true
54 regBankSelected: false
56 tracksRegLiveness: true
69 ; These are legal, so we should find them unchanged in the output
70 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s64), %0(p0)
71 ; CHECK-DAG: {{%[0-9]+}}:_(s64) = G_LOAD %0(p0)
73 %1(s64) = G_LOAD %0(p0) :: (load 8)
74 G_STORE %1(s64), %0(p0) :: (store 8)
78 name: test_constants_s64
79 # CHECK-LABEL: name: test_constants_s64
81 # CHECK: legalized: true
82 regBankSelected: false
84 tracksRegLiveness: true
96 %1(s64) = G_CONSTANT i64 17179869200 ; = 4 * 2 ^ 32 + 16
97 %2(s32), %3(s32) = G_UNMERGE_VALUES %1(s64)
98 G_STORE %2(s32), %0(p0) :: (store 4)
99 G_STORE %3(s32), %0(p0) :: (store 4)
100 ; CHECK-DAG: {{%[0-9]+}}:_(s32) = G_CONSTANT i32 4
101 ; CHECK-DAG: {{%[0-9]+}}:_(s32) = G_CONSTANT i32 16
102 ; CHECK-NOT: G_CONSTANT i64
108 # CHECK-LABEL: name: test_phi_s32
110 # CHECK: legalized: true
111 regBankSelected: false
113 tracksRegLiveness: true
115 - { id: 0, class: _ }
116 - { id: 1, class: _ }
117 - { id: 2, class: _ }
118 - { id: 3, class: _ }
119 - { id: 4, class: _ }
122 liveins: $r0, $r1, $r2
125 %1(s1) = G_TRUNC %0(s32)
130 G_BRCOND %1(s1), %bb.1
137 %4(s32) = G_PHI %2(s32), %bb.0, %3(s32), %bb.1
138 ; G_PHI with s32 is legal, so we should find it unchanged in the output
139 ; CHECK: G_PHI {{%[0-9]+}}(s32), %bb.0, {{%[0-9]+}}(s32), %bb.1
141 BX_RET 14, $noreg, implicit $r0
145 # CHECK-LABEL: name: test_phi_p0
147 # CHECK: legalized: true
148 regBankSelected: false
150 tracksRegLiveness: true
152 - { id: 0, class: _ }
153 - { id: 1, class: _ }
154 - { id: 2, class: _ }
155 - { id: 3, class: _ }
156 - { id: 4, class: _ }
159 liveins: $r0, $r1, $r2
162 %1(s1) = G_TRUNC %0(s32)
167 G_BRCOND %1(s1), %bb.1
174 %4(p0) = G_PHI %2(p0), %bb.0, %3(p0), %bb.1
175 ; G_PHI with p0 is legal, so we should find it unchanged in the output
176 ; CHECK: G_PHI {{%[0-9]+}}(p0), %bb.0, {{%[0-9]+}}(p0), %bb.1
178 BX_RET 14, $noreg, implicit $r0
182 # CHECK-LABEL: name: test_phi_s64
184 # CHECK: legalized: true
185 regBankSelected: false
187 tracksRegLiveness: true
189 - { id: 0, class: _ }
190 - { id: 1, class: _ }
191 - { id: 2, class: _ }
192 - { id: 3, class: _ }
193 - { id: 4, class: _ }
196 liveins: $r0, $d0, $d1
199 %1(s1) = G_TRUNC %0(s32)
204 G_BRCOND %1(s1), %bb.1
211 %4(s64) = G_PHI %2(s64), %bb.0, %3(s64), %bb.1
212 ; G_PHI with s64 is legal when we have floating point support, so we should
213 ; find it unchanged in the output
214 ; CHECK: G_PHI {{%[0-9]+}}(s64), %bb.0, {{%[0-9]+}}(s64), %bb.1
216 BX_RET 14, $noreg, implicit $d0
220 # CHECK-LABEL: name: test_phi_s8
222 # CHECK: legalized: true
223 regBankSelected: false
225 tracksRegLiveness: true
227 - { id: 0, class: _ }
228 - { id: 1, class: _ }
229 - { id: 2, class: _ }
230 - { id: 3, class: _ }
231 - { id: 4, class: _ }
232 - { id: 5, class: _ }
233 - { id: 6, class: _ }
234 - { id: 7, class: _ }
237 liveins: $r0, $r1, $r2
240 %1(s1) = G_TRUNC %0(s32)
243 %3(s8) = G_TRUNC %2(s32)
244 ; CHECK: [[R1:%[0-9]+]]:_(s32) = COPY $r1
247 %5(s8) = G_TRUNC %4(s32)
248 ; CHECK: [[R2:%[0-9]+]]:_(s32) = COPY $r2
250 ; CHECK: [[V1:%[0-9]+]]:_(s32) = COPY [[R1]]
252 G_BRCOND %1(s1), %bb.1
256 ; CHECK: [[V2:%[0-9]+]]:_(s32) = COPY [[R2]]
260 %6(s8) = G_PHI %3(s8), %bb.0, %5(s8), %bb.1
261 ; G_PHI with s8 should widen, and all the truncs and exts should be combined
262 ; away into a bunch of redundant copies
263 ; CHECK: [[V:%[0-9]+]]:_(s32) = G_PHI [[V1]](s32), %bb.0, [[V2]](s32), %bb.1
265 %7(s32) = G_ANYEXT %6(s8)
267 ; CHECK: [[R:%[0-9]+]]:_(s32) = COPY [[V]]
268 ; CHECK: $r0 = COPY [[R]](s32)
269 BX_RET 14, $noreg, implicit $r0
272 name: test_global_variable
273 # CHECK-LABEL: name: test_global_variable
275 # CHECK: legalized: true
276 regBankSelected: false
278 tracksRegLiveness: true
280 - { id: 0, class: _ }
281 - { id: 1, class: _ }
287 %1(p0) = G_GLOBAL_VALUE @a_global
288 ; G_GLOBAL_VALUE is legal, so we should find it unchanged in the output
289 ; CHECK: {{%[0-9]+}}:_(p0) = G_GLOBAL_VALUE @a_global
291 BX_RET 14, $noreg, implicit $r0