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 }
13 attributes #0 = { "target-features"="+vfp2" }
14 attributes #1 = { "target-features"="-vfp2sp" }
17 name: test_legal_loads_stores
18 # CHECK-LABEL: name: test_legal_loads_stores
20 # CHECK: legalized: true
21 regBankSelected: false
23 tracksRegLiveness: true
36 ; These are all legal, so we should find them unchanged in the output
37 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s32), %0(p0) :: (store (s32))
38 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s16), %0(p0) :: (store (s16))
39 ; CHECK-DAG: G_STORE {{%[0-9]+}}(s8), %0(p0) :: (store (s8))
40 ; CHECK-DAG: G_STORE {{%[0-9]+}}(p0), %0(p0)
41 ; CHECK-DAG: {{%[0-9]+}}:_(s32) = G_LOAD %0(p0) :: (load (s32))
42 ; CHECK-DAG: {{%[0-9]+}}:_(s16) = G_LOAD %0(p0) :: (load (s16))
43 ; CHECK-DAG: {{%[0-9]+}}:_(s8) = G_LOAD %0(p0) :: (load (s8))
44 ; CHECK-DAG: {{%[0-9]+}}:_(p0) = G_LOAD %0(p0) :: (load (p0))
46 %2(s32) = G_LOAD %0(p0) :: (load (s32))
47 G_STORE %2(s32), %0(p0) :: (store (s32))
48 %3(s16) = G_LOAD %0(p0) :: (load (s16))
49 G_STORE %3(s16), %0(p0) :: (store (s16))
50 %4(s8) = G_LOAD %0(p0) :: (load (s8))
51 G_STORE %4(s8), %0(p0) :: (store (s8))
52 %6(p0) = G_LOAD %0(p0) :: (load (p0))
53 G_STORE %6(p0), %0(p0) :: (store (p0))
58 name: test_load_store_s1
60 # CHECK: legalized: true
61 regBankSelected: false
63 tracksRegLiveness: true
68 ; CHECK: [[LD:%[0-9]+]]:_(s8) = G_LOAD %0(p0) :: (load (s8))
69 ; CHECK: [[ASSERTZ:%[0-9]+]]:_(s8) = G_ASSERT_ZEXT [[LD]], 1
70 ; CHECK: [[ONE:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
71 ; CHECK: [[EXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ASSERTZ]]
72 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[EXT]], [[ONE]]
73 ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[AND]]
74 ; CHECK: G_STORE [[TRUNC]](s8), {{%[0-9]+}}(p0) :: (store (s8))
76 %5:_(s1) = G_LOAD %0(p0) :: (load (s1))
77 G_STORE %5(s1), %0(p0) :: (store (s1))
81 name: test_load_from_stack
82 # CHECK-LABEL: name: test_load_from_stack
84 # CHECK: legalized: true
85 regBankSelected: false
87 tracksRegLiveness: true
94 - { id: 0, offset: 0, size: 4, alignment: 4, isImmutable: true, isAliased: false }
95 - { id: 1, offset: 4, size: 4, alignment: 4, isImmutable: true, isAliased: false }
96 - { id: 2, offset: 8, size: 4, alignment: 4, isImmutable: true, isAliased: false }
97 # CHECK: id: [[FRAME_INDEX:[0-9]+]], type: default, offset: 8
100 liveins: $r0, $r1, $r2, $r3
102 ; This is legal, so we should find it unchanged in the output
103 ; CHECK: [[FIVREG:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.[[FRAME_INDEX]]
104 ; CHECK: {{%[0-9]+}}:_(s32) = G_LOAD [[FIVREG]](p0) :: (load (s32))
105 %0(p0) = G_FRAME_INDEX %fixed-stack.2
106 %1(s32) = G_LOAD %0(p0) :: (load (s32))
108 BX_RET 14, $noreg, implicit $r0
111 name: test_load_store_64_vfp
112 # CHECK-LABEL: name: test_load_store_64_vfp
114 # CHECK: legalized: true
115 regBankSelected: false
117 tracksRegLiveness: true
119 - { id: 0, class: _ }
120 - { id: 1, class: _ }
121 - { id: 2, class: _ }
126 ; Can't use the VFP support for unaligned operations, we need to use 32-bits
127 ; operations instead.
128 ; CHECK: [[ADDR1:%[0-9]+]]:_(p0) = COPY $r0
129 ; CHECK-NEXT: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32), align 1)
130 ; CHECK-NEXT: [[OFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
131 ; CHECK-NEXT: [[ADDR2:%[0-9]+]]:_(p0) = G_PTR_ADD [[ADDR1]], [[OFF]]
132 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
133 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from unknown-address + 4, align 1)
134 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32), align 1)
135 ; CHECK-NEXT: G_STORE [[V2]](s32), [[ADDR2]](p0) :: (store (s32) into unknown-address + 4, align 1)
137 %1(s64) = G_LOAD %0(p0) :: (load (s64), align 1)
138 G_STORE %1(s64), %0(p0) :: (store (s64), align 1)
140 ; For word-aligned we can use VFP operations.
141 ; CHECK: [[V:%[0-9]+]]:_(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
142 ; CHECK: G_STORE [[V]](s64), %0(p0) :: (store (s64), align 4)
143 %2(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
144 G_STORE %2(s64), %0(p0) :: (store (s64), align 4)
149 name: test_load_store_64_novfp
150 # CHECK-LABEL: name: test_load_store_64_novfp
152 # CHECK: legalized: true
153 regBankSelected: false
155 tracksRegLiveness: true
157 - { id: 0, class: _ }
158 - { id: 1, class: _ }
159 - { id: 2, class: _ }
164 ; When we don't have VFP support, we need to use 32-bit operations.
165 ; CHECK: [[ADDR1:%[0-9]+]]:_(p0) = COPY $r0
166 ; CHECK-NEXT: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32), align 1)
167 ; CHECK-NEXT: [[OFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
168 ; CHECK-NEXT: [[ADDR2:%[0-9]+]]:_(p0) = G_PTR_ADD [[ADDR1]], [[OFF]]
169 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
170 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from unknown-address + 4, align 1)
171 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32), align 1)
172 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
173 ; CHECK-NEXT: G_STORE [[V2]](s32), [[COPY2]](p0) :: (store (s32) into unknown-address + 4, align 1)
175 %1(s64) = G_LOAD %0(p0) :: (load (s64), align 1)
176 G_STORE %1(s64), %0(p0) :: (store (s64), align 1)
178 ; CHECK: [[V1:%[0-9]+]]:_(s32) = G_LOAD [[ADDR1]](p0) :: (load (s32))
179 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(p0) = COPY [[ADDR2]]
180 ; CHECK-NEXT: [[V2:%[0-9]+]]:_(s32) = G_LOAD [[COPY3]](p0) :: (load (s32) from unknown-address + 4)
181 ; CHECK-NEXT: G_STORE [[V1]](s32), [[ADDR1]](p0) :: (store (s32))
182 ; CHECK-NEXT: G_STORE [[V2]](s32), [[ADDR2]](p0) :: (store (s32) into unknown-address + 4)
183 %2(s64) = G_LOAD %0(p0) :: (load (s64), align 4)
184 G_STORE %2(s64), %0(p0) :: (store (s64), align 4)
190 # CHECK-LABEL: name: test_gep_s32
192 # CHECK: legalized: true
193 regBankSelected: false
195 tracksRegLiveness: true
197 - { id: 0, class: _ }
198 - { id: 1, class: _ }
199 - { id: 2, class: _ }
207 ; CHECK: {{%[0-9]+}}:_(p0) = G_PTR_ADD {{%[0-9]+}}, {{%[0-9]+}}(s32)
208 %2(p0) = G_PTR_ADD %0, %1(s32)
211 BX_RET 14, $noreg, implicit $r0