1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --arm-memtransfer-tploop=allow -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve.fp -verify-machineinstrs -tail-predication=enabled -o - %s | FileCheck %s
4 define void @test_memcpy(i32* nocapture %x, i32* nocapture readonly %y, i32 %n, i32 %m) {
5 ; CHECK-LABEL: test_memcpy:
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: .save {r4, r5, r6, r7, lr}
8 ; CHECK-NEXT: push {r4, r5, r6, r7, lr}
9 ; CHECK-NEXT: cmp r2, #1
10 ; CHECK-NEXT: blt .LBB0_5
11 ; CHECK-NEXT: @ %bb.1: @ %for.body.preheader
12 ; CHECK-NEXT: lsl.w r12, r3, #2
13 ; CHECK-NEXT: movs r7, #0
14 ; CHECK-NEXT: b .LBB0_2
15 ; CHECK-NEXT: .LBB0_2: @ %for.body
16 ; CHECK-NEXT: @ =>This Loop Header: Depth=1
17 ; CHECK-NEXT: @ Child Loop BB0_4 Depth 2
18 ; CHECK-NEXT: adds r4, r1, r7
19 ; CHECK-NEXT: adds r5, r0, r7
20 ; CHECK-NEXT: wlstp.8 lr, r3, .LBB0_3
21 ; CHECK-NEXT: b .LBB0_4
22 ; CHECK-NEXT: .LBB0_3: @ %for.body
23 ; CHECK-NEXT: @ in Loop: Header=BB0_2 Depth=1
24 ; CHECK-NEXT: add r7, r12
25 ; CHECK-NEXT: subs r2, #1
26 ; CHECK-NEXT: beq .LBB0_5
27 ; CHECK-NEXT: b .LBB0_2
28 ; CHECK-NEXT: .LBB0_4: @ Parent Loop BB0_2 Depth=1
29 ; CHECK-NEXT: @ => This Inner Loop Header: Depth=2
30 ; CHECK-NEXT: vldrb.u8 q0, [r4], #16
31 ; CHECK-NEXT: vstrb.8 q0, [r5], #16
32 ; CHECK-NEXT: letp lr, .LBB0_4
33 ; CHECK-NEXT: b .LBB0_3
34 ; CHECK-NEXT: .LBB0_5: @ %for.cond.cleanup
35 ; CHECK-NEXT: pop {r4, r5, r6, r7, pc}
37 %cmp8 = icmp sgt i32 %n, 0
38 br i1 %cmp8, label %for.body, label %for.cond.cleanup
40 for.cond.cleanup: ; preds = %for.body, %entry
43 for.body: ; preds = %entry, %for.body
44 %i.011 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
45 %x.addr.010 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
46 %y.addr.09 = phi i32* [ %add.ptr1, %for.body ], [ %y, %entry ]
47 %0 = bitcast i32* %x.addr.010 to i8*
48 %1 = bitcast i32* %y.addr.09 to i8*
49 tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 %m, i1 false)
50 %add.ptr = getelementptr inbounds i32, i32* %x.addr.010, i32 %m
51 %add.ptr1 = getelementptr inbounds i32, i32* %y.addr.09, i32 %m
52 %inc = add nuw nsw i32 %i.011, 1
53 %exitcond.not = icmp eq i32 %inc, %n
54 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
57 define void @test_memset(i32* nocapture %x, i32 %n, i32 %m) {
58 ; CHECK-LABEL: test_memset:
59 ; CHECK: @ %bb.0: @ %entry
60 ; CHECK-NEXT: .save {r4, lr}
61 ; CHECK-NEXT: push {r4, lr}
62 ; CHECK-NEXT: cmp r1, #1
64 ; CHECK-NEXT: poplt {r4, pc}
65 ; CHECK-NEXT: .LBB1_1: @ %for.body.preheader
66 ; CHECK-NEXT: lsl.w r12, r2, #2
67 ; CHECK-NEXT: vmov.i32 q0, #0x0
68 ; CHECK-NEXT: b .LBB1_2
69 ; CHECK-NEXT: .LBB1_2: @ %for.body
70 ; CHECK-NEXT: @ =>This Loop Header: Depth=1
71 ; CHECK-NEXT: @ Child Loop BB1_4 Depth 2
72 ; CHECK-NEXT: mov r4, r0
73 ; CHECK-NEXT: wlstp.8 lr, r2, .LBB1_3
74 ; CHECK-NEXT: b .LBB1_4
75 ; CHECK-NEXT: .LBB1_3: @ %for.body
76 ; CHECK-NEXT: @ in Loop: Header=BB1_2 Depth=1
77 ; CHECK-NEXT: add r0, r12
78 ; CHECK-NEXT: subs r1, #1
79 ; CHECK-NEXT: beq .LBB1_5
80 ; CHECK-NEXT: b .LBB1_2
81 ; CHECK-NEXT: .LBB1_4: @ Parent Loop BB1_2 Depth=1
82 ; CHECK-NEXT: @ => This Inner Loop Header: Depth=2
83 ; CHECK-NEXT: vstrb.8 q0, [r4], #16
84 ; CHECK-NEXT: letp lr, .LBB1_4
85 ; CHECK-NEXT: b .LBB1_3
86 ; CHECK-NEXT: .LBB1_5: @ %for.cond.cleanup
87 ; CHECK-NEXT: pop {r4, pc}
89 %cmp5 = icmp sgt i32 %n, 0
90 br i1 %cmp5, label %for.body, label %for.cond.cleanup
92 for.cond.cleanup: ; preds = %for.body, %entry
95 for.body: ; preds = %entry, %for.body
96 %i.07 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
97 %x.addr.06 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
98 %0 = bitcast i32* %x.addr.06 to i8*
99 tail call void @llvm.memset.p0i8.i32(i8* align 4 %0, i8 0, i32 %m, i1 false)
100 %add.ptr = getelementptr inbounds i32, i32* %x.addr.06, i32 %m
101 %inc = add nuw nsw i32 %i.07, 1
102 %exitcond.not = icmp eq i32 %inc, %n
103 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
106 define void @test_memmove(i32* nocapture %x, i32* nocapture readonly %y, i32 %n, i32 %m) {
107 ; CHECK-LABEL: test_memmove:
108 ; CHECK: @ %bb.0: @ %entry
109 ; CHECK-NEXT: .save {r4, r5, r6, r7, r8, r9, lr}
110 ; CHECK-NEXT: push.w {r4, r5, r6, r7, r8, r9, lr}
111 ; CHECK-NEXT: .pad #4
112 ; CHECK-NEXT: sub sp, #4
113 ; CHECK-NEXT: cmp r2, #1
114 ; CHECK-NEXT: blt .LBB2_3
115 ; CHECK-NEXT: @ %bb.1: @ %for.body.preheader
116 ; CHECK-NEXT: mov r8, r3
117 ; CHECK-NEXT: mov r5, r2
118 ; CHECK-NEXT: mov r9, r1
119 ; CHECK-NEXT: mov r7, r0
120 ; CHECK-NEXT: lsls r4, r3, #2
121 ; CHECK-NEXT: movs r6, #0
122 ; CHECK-NEXT: .LBB2_2: @ %for.body
123 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
124 ; CHECK-NEXT: adds r0, r7, r6
125 ; CHECK-NEXT: add.w r1, r9, r6
126 ; CHECK-NEXT: mov r2, r8
127 ; CHECK-NEXT: bl __aeabi_memmove4
128 ; CHECK-NEXT: add r6, r4
129 ; CHECK-NEXT: subs r5, #1
130 ; CHECK-NEXT: bne .LBB2_2
131 ; CHECK-NEXT: .LBB2_3: @ %for.cond.cleanup
132 ; CHECK-NEXT: add sp, #4
133 ; CHECK-NEXT: pop.w {r4, r5, r6, r7, r8, r9, pc}
135 %cmp8 = icmp sgt i32 %n, 0
136 br i1 %cmp8, label %for.body, label %for.cond.cleanup
138 for.cond.cleanup: ; preds = %for.body, %entry
141 for.body: ; preds = %entry, %for.body
142 %i.011 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
143 %x.addr.010 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
144 %y.addr.09 = phi i32* [ %add.ptr1, %for.body ], [ %y, %entry ]
145 %0 = bitcast i32* %x.addr.010 to i8*
146 %1 = bitcast i32* %y.addr.09 to i8*
147 tail call void @llvm.memmove.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 %m, i1 false)
148 %add.ptr = getelementptr inbounds i32, i32* %x.addr.010, i32 %m
149 %add.ptr1 = getelementptr inbounds i32, i32* %y.addr.09, i32 %m
150 %inc = add nuw nsw i32 %i.011, 1
151 %exitcond.not = icmp eq i32 %inc, %n
152 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
156 define void @test_memcpy16(i32* nocapture %x, i32* nocapture readonly %y, i32 %n) {
157 ; CHECK-LABEL: test_memcpy16:
158 ; CHECK: @ %bb.0: @ %entry
159 ; CHECK-NEXT: .save {r4, lr}
160 ; CHECK-NEXT: push {r4, lr}
161 ; CHECK-NEXT: cmp r2, #1
163 ; CHECK-NEXT: poplt {r4, pc}
164 ; CHECK-NEXT: .LBB3_1: @ %for.body.preheader
165 ; CHECK-NEXT: dls lr, r2
166 ; CHECK-NEXT: .LBB3_2: @ %for.body
167 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
168 ; CHECK-NEXT: ldm.w r1, {r2, r3, r12}
169 ; CHECK-NEXT: ldr r4, [r1, #12]
170 ; CHECK-NEXT: adds r1, #64
171 ; CHECK-NEXT: stm.w r0, {r2, r3, r12}
172 ; CHECK-NEXT: str r4, [r0, #12]
173 ; CHECK-NEXT: adds r0, #64
174 ; CHECK-NEXT: le lr, .LBB3_2
175 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
176 ; CHECK-NEXT: pop {r4, pc}
178 %cmp6 = icmp sgt i32 %n, 0
179 br i1 %cmp6, label %for.body, label %for.cond.cleanup
181 for.cond.cleanup: ; preds = %for.body, %entry
184 for.body: ; preds = %entry, %for.body
185 %i.09 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
186 %x.addr.08 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
187 %y.addr.07 = phi i32* [ %add.ptr1, %for.body ], [ %y, %entry ]
188 %0 = bitcast i32* %x.addr.08 to i8*
189 %1 = bitcast i32* %y.addr.07 to i8*
190 tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* nonnull align 4 dereferenceable(16) %0, i8* nonnull align 4 dereferenceable(16) %1, i32 16, i1 false)
191 %add.ptr = getelementptr inbounds i32, i32* %x.addr.08, i32 16
192 %add.ptr1 = getelementptr inbounds i32, i32* %y.addr.07, i32 16
193 %inc = add nuw nsw i32 %i.09, 1
194 %exitcond.not = icmp eq i32 %inc, %n
195 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
198 define void @test_memset16(i32* nocapture %x, i32 %n) {
199 ; CHECK-LABEL: test_memset16:
200 ; CHECK: @ %bb.0: @ %entry
201 ; CHECK-NEXT: .save {r7, lr}
202 ; CHECK-NEXT: push {r7, lr}
203 ; CHECK-NEXT: cmp r1, #1
205 ; CHECK-NEXT: poplt {r7, pc}
206 ; CHECK-NEXT: .LBB4_1: @ %for.body.preheader
207 ; CHECK-NEXT: dls lr, r1
208 ; CHECK-NEXT: movs r1, #0
209 ; CHECK-NEXT: .LBB4_2: @ %for.body
210 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
211 ; CHECK-NEXT: strd r1, r1, [r0]
212 ; CHECK-NEXT: strd r1, r1, [r0, #8]
213 ; CHECK-NEXT: adds r0, #64
214 ; CHECK-NEXT: le lr, .LBB4_2
215 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
216 ; CHECK-NEXT: pop {r7, pc}
218 %cmp4 = icmp sgt i32 %n, 0
219 br i1 %cmp4, label %for.body, label %for.cond.cleanup
221 for.cond.cleanup: ; preds = %for.body, %entry
224 for.body: ; preds = %entry, %for.body
225 %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
226 %x.addr.05 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
227 %0 = bitcast i32* %x.addr.05 to i8*
228 tail call void @llvm.memset.p0i8.i32(i8* nonnull align 4 dereferenceable(16) %0, i8 0, i32 16, i1 false)
229 %add.ptr = getelementptr inbounds i32, i32* %x.addr.05, i32 16
230 %inc = add nuw nsw i32 %i.06, 1
231 %exitcond.not = icmp eq i32 %inc, %n
232 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
235 define void @test_memmove16(i32* nocapture %x, i32* nocapture readonly %y, i32 %n) {
236 ; CHECK-LABEL: test_memmove16:
237 ; CHECK: @ %bb.0: @ %entry
238 ; CHECK-NEXT: .save {r4, lr}
239 ; CHECK-NEXT: push {r4, lr}
240 ; CHECK-NEXT: cmp r2, #1
242 ; CHECK-NEXT: poplt {r4, pc}
243 ; CHECK-NEXT: .LBB5_1: @ %for.body.preheader
244 ; CHECK-NEXT: dls lr, r2
245 ; CHECK-NEXT: .LBB5_2: @ %for.body
246 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
247 ; CHECK-NEXT: ldm.w r1, {r2, r3, r12}
248 ; CHECK-NEXT: ldr r4, [r1, #12]
249 ; CHECK-NEXT: adds r1, #64
250 ; CHECK-NEXT: stm.w r0, {r2, r3, r12}
251 ; CHECK-NEXT: str r4, [r0, #12]
252 ; CHECK-NEXT: adds r0, #64
253 ; CHECK-NEXT: le lr, .LBB5_2
254 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
255 ; CHECK-NEXT: pop {r4, pc}
257 %cmp6 = icmp sgt i32 %n, 0
258 br i1 %cmp6, label %for.body, label %for.cond.cleanup
260 for.cond.cleanup: ; preds = %for.body, %entry
263 for.body: ; preds = %entry, %for.body
264 %i.09 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
265 %x.addr.08 = phi i32* [ %add.ptr, %for.body ], [ %x, %entry ]
266 %y.addr.07 = phi i32* [ %add.ptr1, %for.body ], [ %y, %entry ]
267 %0 = bitcast i32* %x.addr.08 to i8*
268 %1 = bitcast i32* %y.addr.07 to i8*
269 tail call void @llvm.memmove.p0i8.p0i8.i32(i8* nonnull align 4 dereferenceable(16) %0, i8* nonnull align 4 dereferenceable(16) %1, i32 16, i1 false)
270 %add.ptr = getelementptr inbounds i32, i32* %x.addr.08, i32 16
271 %add.ptr1 = getelementptr inbounds i32, i32* %y.addr.07, i32 16
272 %inc = add nuw nsw i32 %i.09, 1
273 %exitcond.not = icmp eq i32 %inc, %n
274 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
277 define void @test_memset_preheader(i8* %x, i8* %y, i32 %n) {
278 ; CHECK-LABEL: test_memset_preheader:
279 ; CHECK: @ %bb.0: @ %entry
280 ; CHECK-NEXT: .save {r7, lr}
281 ; CHECK-NEXT: push {r7, lr}
282 ; CHECK-NEXT: cbz r2, .LBB6_5
283 ; CHECK-NEXT: @ %bb.1: @ %prehead
284 ; CHECK-NEXT: vmov.i32 q0, #0x0
285 ; CHECK-NEXT: mov r12, r0
286 ; CHECK-NEXT: wlstp.8 lr, r2, .LBB6_3
287 ; CHECK-NEXT: .LBB6_2: @ =>This Inner Loop Header: Depth=1
288 ; CHECK-NEXT: vstrb.8 q0, [r12], #16
289 ; CHECK-NEXT: letp lr, .LBB6_2
290 ; CHECK-NEXT: .LBB6_3: @ %prehead
291 ; CHECK-NEXT: dls lr, r2
292 ; CHECK-NEXT: mov r12, r0
293 ; CHECK-NEXT: .LBB6_4: @ %for.body
294 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
295 ; CHECK-NEXT: ldrb r3, [r12], #1
296 ; CHECK-NEXT: strb r3, [r1], #1
297 ; CHECK-NEXT: le lr, .LBB6_4
298 ; CHECK-NEXT: .LBB6_5: @ %for.cond.cleanup
299 ; CHECK-NEXT: vmov.i32 q0, #0x0
300 ; CHECK-NEXT: wlstp.8 lr, r2, .LBB6_7
301 ; CHECK-NEXT: .LBB6_6: @ =>This Inner Loop Header: Depth=1
302 ; CHECK-NEXT: vstrb.8 q0, [r0], #16
303 ; CHECK-NEXT: letp lr, .LBB6_6
304 ; CHECK-NEXT: .LBB6_7: @ %for.cond.cleanup
305 ; CHECK-NEXT: pop {r7, pc}
307 %cmp6 = icmp ne i32 %n, 0
308 br i1 %cmp6, label %prehead, label %for.cond.cleanup
311 call void @llvm.memset.p0i8.i32(i8* %x, i8 0, i32 %n, i1 false)
314 for.body: ; preds = %entry, %for.body
315 %i.09 = phi i32 [ %inc, %for.body ], [ 0, %prehead ]
316 %x.addr.08 = phi i8* [ %add.ptr, %for.body ], [ %x, %prehead ]
317 %y.addr.07 = phi i8* [ %add.ptr1, %for.body ], [ %y, %prehead ]
318 %add.ptr = getelementptr inbounds i8, i8* %x.addr.08, i32 1
319 %add.ptr1 = getelementptr inbounds i8, i8* %y.addr.07, i32 1
320 %l = load i8, i8* %x.addr.08
321 store i8 %l, i8* %y.addr.07
322 %inc = add nuw nsw i32 %i.09, 1
323 %exitcond.not = icmp eq i32 %inc, %n
324 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
326 for.cond.cleanup: ; preds = %for.body, %entry
327 call void @llvm.memset.p0i8.i32(i8* %x, i8 0, i32 %n, i1 false)
333 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg)
334 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg)
335 declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1 immarg)