1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve.fp -o - %s | FileCheck --check-prefix=CHECK %s
4 define void @tailpred(half* nocapture readonly %pSrcA, half* nocapture readonly %pSrcB, half* nocapture %pDst, i32 %blockSize) {
5 ; CHECK-LABEL: tailpred:
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: .save {r4, r5, r7, lr}
8 ; CHECK-NEXT: push {r4, r5, r7, lr}
9 ; CHECK-NEXT: cmp r3, #0
10 ; CHECK-NEXT: beq .LBB0_6
11 ; CHECK-NEXT: @ %bb.1: @ %vector.memcheck
12 ; CHECK-NEXT: add.w r5, r2, r3, lsl #1
13 ; CHECK-NEXT: add.w r4, r1, r3, lsl #1
14 ; CHECK-NEXT: cmp r5, r1
15 ; CHECK-NEXT: cset r12, hi
16 ; CHECK-NEXT: cmp r4, r2
17 ; CHECK-NEXT: cset lr, hi
18 ; CHECK-NEXT: cmp r5, r0
19 ; CHECK-NEXT: add.w r5, r0, r3, lsl #1
20 ; CHECK-NEXT: cset r4, hi
21 ; CHECK-NEXT: cmp r5, r2
22 ; CHECK-NEXT: cset r5, hi
23 ; CHECK-NEXT: tst r5, r4
25 ; CHECK-NEXT: andseq.w r5, lr, r12
26 ; CHECK-NEXT: beq .LBB0_4
27 ; CHECK-NEXT: @ %bb.2: @ %while.body.preheader
28 ; CHECK-NEXT: dls lr, r3
29 ; CHECK-NEXT: .LBB0_3: @ %while.body
30 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
31 ; CHECK-NEXT: vldr.16 s0, [r0]
32 ; CHECK-NEXT: vldr.16 s2, [r1]
33 ; CHECK-NEXT: adds r1, #2
34 ; CHECK-NEXT: adds r0, #2
35 ; CHECK-NEXT: vadd.f16 s0, s2, s0
36 ; CHECK-NEXT: vstr.16 s0, [r2]
37 ; CHECK-NEXT: adds r2, #2
38 ; CHECK-NEXT: le lr, .LBB0_3
39 ; CHECK-NEXT: b .LBB0_6
40 ; CHECK-NEXT: .LBB0_4: @ %vector.ph
41 ; CHECK-NEXT: dlstp.16 lr, r3
42 ; CHECK-NEXT: .LBB0_5: @ %vector.body
43 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
44 ; CHECK-NEXT: vldrh.u16 q0, [r0], #16
45 ; CHECK-NEXT: vldrh.u16 q1, [r1], #16
46 ; CHECK-NEXT: vadd.f16 q0, q1, q0
47 ; CHECK-NEXT: vstrh.16 q0, [r2], #16
48 ; CHECK-NEXT: letp lr, .LBB0_5
49 ; CHECK-NEXT: .LBB0_6: @ %while.end
50 ; CHECK-NEXT: pop {r4, r5, r7, pc}
52 %cmp.not6 = icmp eq i32 %blockSize, 0
53 br i1 %cmp.not6, label %while.end, label %vector.memcheck
55 vector.memcheck: ; preds = %entry
56 %scevgep = getelementptr half, half* %pDst, i32 %blockSize
57 %scevgep14 = getelementptr half, half* %pSrcA, i32 %blockSize
58 %scevgep17 = getelementptr half, half* %pSrcB, i32 %blockSize
59 %bound0 = icmp ugt half* %scevgep14, %pDst
60 %bound1 = icmp ugt half* %scevgep, %pSrcA
61 %found.conflict = and i1 %bound0, %bound1
62 %bound019 = icmp ugt half* %scevgep17, %pDst
63 %bound120 = icmp ugt half* %scevgep, %pSrcB
64 %found.conflict21 = and i1 %bound019, %bound120
65 %conflict.rdx = or i1 %found.conflict, %found.conflict21
66 br i1 %conflict.rdx, label %while.body, label %vector.ph
68 vector.ph: ; preds = %vector.memcheck
69 %n.rnd.up = add i32 %blockSize, 7
70 %n.vec = and i32 %n.rnd.up, -8
73 vector.body: ; preds = %vector.body, %vector.ph
74 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
75 %next.gep = getelementptr half, half* %pSrcA, i32 %index
76 %next.gep28 = getelementptr half, half* %pDst, i32 %index
77 %next.gep29 = getelementptr half, half* %pSrcB, i32 %index
78 %active.lane.mask = call <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32 %index, i32 %blockSize)
79 %0 = bitcast half* %next.gep to <8 x half>*
80 %wide.masked.load = call <8 x half> @llvm.masked.load.v8f16.p0v8f16(<8 x half>* %0, i32 2, <8 x i1> %active.lane.mask, <8 x half> undef)
81 %1 = bitcast half* %next.gep29 to <8 x half>*
82 %wide.masked.load32 = call <8 x half> @llvm.masked.load.v8f16.p0v8f16(<8 x half>* %1, i32 2, <8 x i1> %active.lane.mask, <8 x half> undef)
83 %2 = fadd fast <8 x half> %wide.masked.load32, %wide.masked.load
84 %3 = bitcast half* %next.gep28 to <8 x half>*
85 call void @llvm.masked.store.v8f16.p0v8f16(<8 x half> %2, <8 x half>* %3, i32 2, <8 x i1> %active.lane.mask)
86 %index.next = add i32 %index, 8
87 %4 = icmp eq i32 %index.next, %n.vec
88 br i1 %4, label %while.end, label %vector.body
90 while.body: ; preds = %vector.memcheck, %while.body
91 %blkCnt.010 = phi i32 [ %dec, %while.body ], [ %blockSize, %vector.memcheck ]
92 %pSrcA.addr.09 = phi half* [ %incdec.ptr, %while.body ], [ %pSrcA, %vector.memcheck ]
93 %pDst.addr.08 = phi half* [ %incdec.ptr3, %while.body ], [ %pDst, %vector.memcheck ]
94 %pSrcB.addr.07 = phi half* [ %incdec.ptr1, %while.body ], [ %pSrcB, %vector.memcheck ]
95 %incdec.ptr = getelementptr inbounds half, half* %pSrcA.addr.09, i32 1
96 %5 = load half, half* %pSrcA.addr.09, align 2
97 %incdec.ptr1 = getelementptr inbounds half, half* %pSrcB.addr.07, i32 1
98 %6 = load half, half* %pSrcB.addr.07, align 2
99 %7 = fadd fast half %6, %5
100 %incdec.ptr3 = getelementptr inbounds half, half* %pDst.addr.08, i32 1
101 store half %7, half* %pDst.addr.08, align 2
102 %dec = add i32 %blkCnt.010, -1
103 %cmp.not = icmp eq i32 %dec, 0
104 br i1 %cmp.not, label %while.end, label %while.body
106 while.end: ; preds = %vector.body, %while.body, %entry
110 define void @notailpred(half* nocapture readonly %pSrcA, half* nocapture readonly %pSrcB, half* nocapture %pDst, i32 %blockSize) {
111 ; CHECK-LABEL: notailpred:
112 ; CHECK: @ %bb.0: @ %entry
113 ; CHECK-NEXT: .save {r4, r5, r6, r7, lr}
114 ; CHECK-NEXT: push {r4, r5, r6, r7, lr}
115 ; CHECK-NEXT: cbz r3, .LBB1_6
116 ; CHECK-NEXT: @ %bb.1: @ %while.body.preheader
117 ; CHECK-NEXT: cmp r3, #8
118 ; CHECK-NEXT: blo .LBB1_3
119 ; CHECK-NEXT: @ %bb.2: @ %vector.memcheck
120 ; CHECK-NEXT: add.w r5, r2, r3, lsl #1
121 ; CHECK-NEXT: add.w r6, r1, r3, lsl #1
122 ; CHECK-NEXT: cmp r5, r1
123 ; CHECK-NEXT: add.w r4, r0, r3, lsl #1
124 ; CHECK-NEXT: cset r7, hi
125 ; CHECK-NEXT: cmp r6, r2
126 ; CHECK-NEXT: cset r6, hi
127 ; CHECK-NEXT: cmp r5, r0
128 ; CHECK-NEXT: cset r5, hi
129 ; CHECK-NEXT: cmp r4, r2
130 ; CHECK-NEXT: cset r4, hi
131 ; CHECK-NEXT: tst r4, r5
133 ; CHECK-NEXT: andseq.w r7, r7, r6
134 ; CHECK-NEXT: beq .LBB1_7
135 ; CHECK-NEXT: .LBB1_3:
136 ; CHECK-NEXT: mov r5, r3
137 ; CHECK-NEXT: mov r12, r0
138 ; CHECK-NEXT: mov r7, r2
139 ; CHECK-NEXT: mov r4, r1
140 ; CHECK-NEXT: .LBB1_4: @ %while.body.preheader31
141 ; CHECK-NEXT: dls lr, r5
142 ; CHECK-NEXT: .LBB1_5: @ %while.body
143 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
144 ; CHECK-NEXT: vldr.16 s0, [r12]
145 ; CHECK-NEXT: vldr.16 s2, [r4]
146 ; CHECK-NEXT: adds r4, #2
147 ; CHECK-NEXT: add.w r12, r12, #2
148 ; CHECK-NEXT: vadd.f16 s0, s2, s0
149 ; CHECK-NEXT: vstr.16 s0, [r7]
150 ; CHECK-NEXT: adds r7, #2
151 ; CHECK-NEXT: le lr, .LBB1_5
152 ; CHECK-NEXT: .LBB1_6: @ %while.end
153 ; CHECK-NEXT: pop {r4, r5, r6, r7, pc}
154 ; CHECK-NEXT: .LBB1_7: @ %vector.ph
155 ; CHECK-NEXT: bic r6, r3, #7
156 ; CHECK-NEXT: movs r5, #1
157 ; CHECK-NEXT: sub.w r7, r6, #8
158 ; CHECK-NEXT: add.w r4, r1, r6, lsl #1
159 ; CHECK-NEXT: add.w r12, r0, r6, lsl #1
160 ; CHECK-NEXT: add.w lr, r5, r7, lsr #3
161 ; CHECK-NEXT: add.w r7, r2, r6, lsl #1
162 ; CHECK-NEXT: and r5, r3, #7
163 ; CHECK-NEXT: .LBB1_8: @ %vector.body
164 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
165 ; CHECK-NEXT: vldrh.u16 q0, [r0], #16
166 ; CHECK-NEXT: vldrh.u16 q1, [r1], #16
167 ; CHECK-NEXT: vadd.f16 q0, q1, q0
168 ; CHECK-NEXT: vstrb.8 q0, [r2], #16
169 ; CHECK-NEXT: le lr, .LBB1_8
170 ; CHECK-NEXT: @ %bb.9: @ %middle.block
171 ; CHECK-NEXT: cmp r6, r3
172 ; CHECK-NEXT: bne .LBB1_4
173 ; CHECK-NEXT: b .LBB1_6
175 %cmp.not6 = icmp eq i32 %blockSize, 0
176 br i1 %cmp.not6, label %while.end, label %while.body.preheader
178 while.body.preheader: ; preds = %entry
179 %min.iters.check = icmp ult i32 %blockSize, 8
180 br i1 %min.iters.check, label %while.body.preheader31, label %vector.memcheck
182 vector.memcheck: ; preds = %while.body.preheader
183 %scevgep = getelementptr half, half* %pDst, i32 %blockSize
184 %scevgep14 = getelementptr half, half* %pSrcA, i32 %blockSize
185 %scevgep17 = getelementptr half, half* %pSrcB, i32 %blockSize
186 %bound0 = icmp ugt half* %scevgep14, %pDst
187 %bound1 = icmp ugt half* %scevgep, %pSrcA
188 %found.conflict = and i1 %bound0, %bound1
189 %bound019 = icmp ugt half* %scevgep17, %pDst
190 %bound120 = icmp ugt half* %scevgep, %pSrcB
191 %found.conflict21 = and i1 %bound019, %bound120
192 %conflict.rdx = or i1 %found.conflict, %found.conflict21
193 br i1 %conflict.rdx, label %while.body.preheader31, label %vector.ph
195 vector.ph: ; preds = %vector.memcheck
196 %n.vec = and i32 %blockSize, -8
197 %ind.end = and i32 %blockSize, 7
198 %ind.end23 = getelementptr half, half* %pSrcA, i32 %n.vec
199 %ind.end25 = getelementptr half, half* %pDst, i32 %n.vec
200 %ind.end27 = getelementptr half, half* %pSrcB, i32 %n.vec
201 br label %vector.body
203 vector.body: ; preds = %vector.body, %vector.ph
204 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
205 %next.gep = getelementptr half, half* %pSrcA, i32 %index
206 %next.gep28 = getelementptr half, half* %pDst, i32 %index
207 %next.gep29 = getelementptr half, half* %pSrcB, i32 %index
208 %0 = bitcast half* %next.gep to <8 x half>*
209 %wide.load = load <8 x half>, <8 x half>* %0, align 2
210 %1 = bitcast half* %next.gep29 to <8 x half>*
211 %wide.load30 = load <8 x half>, <8 x half>* %1, align 2
212 %2 = fadd fast <8 x half> %wide.load30, %wide.load
213 %3 = bitcast half* %next.gep28 to <8 x half>*
214 store <8 x half> %2, <8 x half>* %3, align 2
215 %index.next = add i32 %index, 8
216 %4 = icmp eq i32 %index.next, %n.vec
217 br i1 %4, label %middle.block, label %vector.body
219 middle.block: ; preds = %vector.body
220 %cmp.n = icmp eq i32 %n.vec, %blockSize
221 br i1 %cmp.n, label %while.end, label %while.body.preheader31
223 while.body.preheader31: ; preds = %middle.block, %vector.memcheck, %while.body.preheader
224 %blkCnt.010.ph = phi i32 [ %blockSize, %vector.memcheck ], [ %blockSize, %while.body.preheader ], [ %ind.end, %middle.block ]
225 %pSrcA.addr.09.ph = phi half* [ %pSrcA, %vector.memcheck ], [ %pSrcA, %while.body.preheader ], [ %ind.end23, %middle.block ]
226 %pDst.addr.08.ph = phi half* [ %pDst, %vector.memcheck ], [ %pDst, %while.body.preheader ], [ %ind.end25, %middle.block ]
227 %pSrcB.addr.07.ph = phi half* [ %pSrcB, %vector.memcheck ], [ %pSrcB, %while.body.preheader ], [ %ind.end27, %middle.block ]
230 while.body: ; preds = %while.body.preheader31, %while.body
231 %blkCnt.010 = phi i32 [ %dec, %while.body ], [ %blkCnt.010.ph, %while.body.preheader31 ]
232 %pSrcA.addr.09 = phi half* [ %incdec.ptr, %while.body ], [ %pSrcA.addr.09.ph, %while.body.preheader31 ]
233 %pDst.addr.08 = phi half* [ %incdec.ptr3, %while.body ], [ %pDst.addr.08.ph, %while.body.preheader31 ]
234 %pSrcB.addr.07 = phi half* [ %incdec.ptr1, %while.body ], [ %pSrcB.addr.07.ph, %while.body.preheader31 ]
235 %incdec.ptr = getelementptr inbounds half, half* %pSrcA.addr.09, i32 1
236 %5 = load half, half* %pSrcA.addr.09, align 2
237 %incdec.ptr1 = getelementptr inbounds half, half* %pSrcB.addr.07, i32 1
238 %6 = load half, half* %pSrcB.addr.07, align 2
239 %7 = fadd fast half %6, %5
240 %incdec.ptr3 = getelementptr inbounds half, half* %pDst.addr.08, i32 1
241 store half %7, half* %pDst.addr.08, align 2
242 %dec = add i32 %blkCnt.010, -1
243 %cmp.not = icmp eq i32 %dec, 0
244 br i1 %cmp.not, label %while.end, label %while.body
246 while.end: ; preds = %while.body, %middle.block, %entry
250 declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32, i32) #1
251 declare <8 x half> @llvm.masked.load.v8f16.p0v8f16(<8 x half>*, i32 immarg, <8 x i1>, <8 x half>) #2
252 declare void @llvm.masked.store.v8f16.p0v8f16(<8 x half>, <8 x half>*, i32 immarg, <8 x i1>) #3