1 # RUN: llc -mtriple arm-- -run-pass=legalizer %s -o - | FileCheck %s
2 # RUN: llc -mtriple thumbv7-- -run-pass=legalizer %s -o - | FileCheck %s
4 define void @test_legal_loads_stores() { ret void }
5 define void @test_load_store_s1() { ret void }
6 define void @test_load_from_stack() { ret void }
8 define void @test_load_store_64_vfp() #0 { ret void }
9 define void @test_load_store_64_novfp() #1 { ret void }
11 define void @test_gep_s32() { ret void }
12 define void @test_gep_s16() { ret void }
14 attributes #0 = { "target-features"="+vfp2" }
15 attributes #1 = { "target-features"="-vfp2sp" }
18 name: test_legal_loads_stores
19 # CHECK-LABEL: name: test_legal_loads_stores
21 # CHECK: legalized: true
22 regBankSelected: false
24 tracksRegLiveness: true
37 ; These are all legal, so we should find them unchanged in the output
38 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s32), %0(p0) :: (store (s32))
39 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s16), %0(p0) :: (store (s16))
40 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s8), %0(p0) :: (store (s8))
41 ; CHECK-DAG: G_STORE {{%[0-9]+}}(p0), %0(p0)
42 ; CHECK-DAG: {{%[0-9]+}}:_(s32) = G_LOAD %0(p0) :: (load (s32))
43 ; CHECK-DAG: {{%[0-9]+}}:_(s16) = G_LOAD %0(p0) :: (load (s16))
44 ; CHECK-DAG: {{%[0-9]+}}:_(s8) = G_LOAD %0(p0) :: (load (s8))
45 ; CHECK-DAG: {{%[0-9]+}}:_(p0) = G_LOAD %0(p0) :: (load (p0))
47 %2(s32) = G_LOAD %0(p0) :: (load (s32))
48 G_STORE %2(s32), %0(p0) :: (store (s32))
49 %3(s16) = G_LOAD %0(p0) :: (load (s16))
50 G_STORE %3(s16), %0(p0) :: (store (s16))
51 %4(s8) = G_LOAD %0(p0) :: (load (s8))
52 G_STORE %4(s8), %0(p0) :: (store (s8))
53 %6(p0) = G_LOAD %0(p0) :: (load (p0))
54 G_STORE %6(p0), %0(p0) :: (store (p0))
59 name: test_load_store_s1
61 # CHECK: legalized: true
62 regBankSelected: false
64 tracksRegLiveness: true
69 ; CHECK: [[LD:%[0-9]+]]:_(s8) = G_LOAD %0(p0) :: (load (s8))
70 ; CHECK: [[ASSERTZ:%[0-9]+]]:_(s8) = G_ASSERT_ZEXT [[LD]], 1
71 ; CHECK: [[ONE:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
72 ; CHECK: [[EXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASSERTZ]]
73 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[EXT]], [[ONE]]
74 ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[AND]]
75 ; CHECK: G_STORE [[TRUNC]](s8), {{%[0-9]+}}(p0) :: (store (s8))
77 %5:_(s1) = G_LOAD %0(p0) :: (load (s1))
78 G_STORE %5(s1), %0(p0) :: (store (s1))
82 name: test_load_from_stack
83 # CHECK-LABEL: name: test_load_from_stack
85 # CHECK: legalized: true
86 regBankSelected: false
88 tracksRegLiveness: true
95 - { id: 0, offset: 0, size: 4, alignment: 4, isImmutable: true, isAliased: false }
96 - { id: 1, offset: 4, size: 4, alignment: 4, isImmutable: true, isAliased: false }
97 - { id: 2, offset: 8, size: 4, alignment: 4, isImmutable: true, isAliased: false }
98 # CHECK: id: [[FRAME_INDEX:[0-9]+]], type: default, offset: 8
101 liveins: $r0, $r1, $r2, $r3
103 ; This is legal, so we should find it unchanged in the output
104 ; CHECK: [[FIVREG:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[FRAME_INDEX]]
105 ; CHECK: {{%[0-9]+}}:_(s32) = G_LOAD [[FIVREG]](p0) :: (load (s32))
106 %0(p0) = G_FRAME_INDEX %fixed-stack.2
107 %1(s32) = G_LOAD %0(p0) :: (load (s32))
109 BX_RET 14, $noreg, implicit $r0
112 name: test_load_store_64_vfp
113 # CHECK-LABEL: name: test_load_store_64_vfp
115 # CHECK: legalized: true
116 regBankSelected: false
118 tracksRegLiveness: true
120 - { id: 0, class: _ }
121 - { id: 1, class: _ }
122 - { id: 2, class: _ }
127 ; Can't use the VFP support for unaligned operations, we need to use 32-bits
128 ; operations instead.
129 ; CHECK: [[ADDR1:%[0-9]+]]:_(p0) = COPY $r0
130 ; CHECK-NEXT: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32), align 1)
131 ; CHECK-NEXT: [[OFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
132 ; CHECK-NEXT: [[ADDR2:%[0-9]+]]:_(p0) = G_PTR_ADD [[ADDR1]], [[OFF]]
133 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
134 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from unknown-address + 4, align 1)
135 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32), align 1)
136 ; CHECK-NEXT: G_STORE [[V2]](s32), [[ADDR2]](p0) :: (store (s32) into unknown-address + 4, align 1)
138 %1(s64) = G_LOAD %0(p0) :: (load (s64), align 1)
139 G_STORE %1(s64), %0(p0) :: (store (s64), align 1)
141 ; For word-aligned we can use VFP operations.
142 ; CHECK: [[V:%[0-9]+]]:_(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
143 ; CHECK: G_STORE [[V]](s64), %0(p0) :: (store (s64), align 4)
144 %2(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
145 G_STORE %2(s64), %0(p0) :: (store (s64), align 4)
150 name: test_load_store_64_novfp
151 # CHECK-LABEL: name: test_load_store_64_novfp
153 # CHECK: legalized: true
154 regBankSelected: false
156 tracksRegLiveness: true
158 - { id: 0, class: _ }
159 - { id: 1, class: _ }
160 - { id: 2, class: _ }
165 ; When we don't have VFP support, we need to use 32-bit operations.
166 ; CHECK: [[ADDR1:%[0-9]+]]:_(p0) = COPY $r0
167 ; CHECK-NEXT: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32), align 1)
168 ; CHECK-NEXT: [[OFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
169 ; CHECK-NEXT: [[ADDR2:%[0-9]+]]:_(p0) = G_PTR_ADD [[ADDR1]], [[OFF]]
170 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
171 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from unknown-address + 4, align 1)
172 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32), align 1)
173 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
174 ; CHECK-NEXT: G_STORE [[V2]](s32), [[COPY2]](p0) :: (store (s32) into unknown-address + 4, align 1)
176 %1(s64) = G_LOAD %0(p0) :: (load (s64), align 1)
177 G_STORE %1(s64), %0(p0) :: (store (s64), align 1)
179 ; CHECK: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32))
180 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
181 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY3]](p0) :: (load (s32) from unknown-address + 4)
182 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32))
183 ; CHECK-NEXT: G_STORE [[V2]](s32), [[ADDR2]](p0) :: (store (s32) into unknown-address + 4)
184 %2(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
185 G_STORE %2(s64), %0(p0) :: (store (s64), align 4)
191 # CHECK-LABEL: name: test_gep_s32
193 # CHECK: legalized: true
194 regBankSelected: false
196 tracksRegLiveness: true
198 - { id: 0, class: _ }
199 - { id: 1, class: _ }
200 - { id: 2, class: _ }
208 ; CHECK: {{%[0-9]+}}:_(p0) = G_PTR_ADD {{%[0-9]+}}, {{%[0-9]+}}(s32)
209 %2(p0) = G_PTR_ADD %0, %1(s32)
212 BX_RET 14, $noreg, implicit $r0
216 # CHECK-LABEL: name: test_gep_s16
218 # CHECK: legalized: true
219 regBankSelected: false
221 tracksRegLiveness: true
223 - { id: 0, class: _ }
224 - { id: 1, class: _ }
225 - { id: 2, class: _ }
231 %1(s16) = G_LOAD %0(p0) :: (load (s16))
233 ; CHECK-NOT: G_PTR_ADD {{%[0-9]+}}, {{%[0-9]+}}(s16)
234 ; CHECK: {{%[0-9]+}}:_(p0) = G_PTR_ADD {{%[0-9]+}}, {{%[0-9]+}}(s32)
235 ; CHECK-NOT: G_PTR_ADD {{%[0-9]+}}, {{%[0-9]+}}(s16)
236 %2(p0) = G_PTR_ADD %0, %1(s16)
239 BX_RET 14, $noreg, implicit $r0