1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=arm-eabi -mattr=+neon %s -o - | FileCheck %s
3 ; Implement ctpop with vcnt
5 define <8 x i8> @vcnt8(<8 x i8>* %A) nounwind {
8 ; CHECK-NEXT: vldr d16, [r0]
9 ; CHECK-NEXT: vcnt.8 d16, d16
10 ; CHECK-NEXT: vmov r0, r1, d16
11 ; CHECK-NEXT: mov pc, lr
12 %tmp1 = load <8 x i8>, <8 x i8>* %A
13 %tmp2 = call <8 x i8> @llvm.ctpop.v8i8(<8 x i8> %tmp1)
17 define <16 x i8> @vcntQ8(<16 x i8>* %A) nounwind {
18 ; CHECK-LABEL: vcntQ8:
20 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
21 ; CHECK-NEXT: vcnt.8 q8, q8
22 ; CHECK-NEXT: vmov r0, r1, d16
23 ; CHECK-NEXT: vmov r2, r3, d17
24 ; CHECK-NEXT: mov pc, lr
25 %tmp1 = load <16 x i8>, <16 x i8>* %A
26 %tmp2 = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %tmp1)
30 define <4 x i16> @vcnt16(<4 x i16>* %A) nounwind {
31 ; CHECK-LABEL: vcnt16:
33 ; CHECK-NEXT: vldr d16, [r0]
34 ; CHECK-NEXT: vcnt.8 d16, d16
35 ; CHECK-NEXT: vpaddl.u8 d16, d16
36 ; CHECK-NEXT: vmov r0, r1, d16
37 ; CHECK-NEXT: mov pc, lr
38 %tmp1 = load <4 x i16>, <4 x i16>* %A
39 %tmp2 = call <4 x i16> @llvm.ctpop.v4i16(<4 x i16> %tmp1)
43 define <8 x i16> @vcntQ16(<8 x i16>* %A) nounwind {
44 ; CHECK-LABEL: vcntQ16:
46 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
47 ; CHECK-NEXT: vcnt.8 q8, q8
48 ; CHECK-NEXT: vpaddl.u8 q8, q8
49 ; CHECK-NEXT: vmov r0, r1, d16
50 ; CHECK-NEXT: vmov r2, r3, d17
51 ; CHECK-NEXT: mov pc, lr
52 %tmp1 = load <8 x i16>, <8 x i16>* %A
53 %tmp2 = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %tmp1)
57 define <2 x i32> @vcnt32(<2 x i32>* %A) nounwind {
58 ; CHECK-LABEL: vcnt32:
60 ; CHECK-NEXT: vldr d16, [r0]
61 ; CHECK-NEXT: vcnt.8 d16, d16
62 ; CHECK-NEXT: vpaddl.u8 d16, d16
63 ; CHECK-NEXT: vpaddl.u16 d16, d16
64 ; CHECK-NEXT: vmov r0, r1, d16
65 ; CHECK-NEXT: mov pc, lr
66 %tmp1 = load <2 x i32>, <2 x i32>* %A
67 %tmp2 = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %tmp1)
71 define <4 x i32> @vcntQ32(<4 x i32>* %A) nounwind {
72 ; CHECK-LABEL: vcntQ32:
74 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
75 ; CHECK-NEXT: vcnt.8 q8, q8
76 ; CHECK-NEXT: vpaddl.u8 q8, q8
77 ; CHECK-NEXT: vpaddl.u16 q8, q8
78 ; CHECK-NEXT: vmov r0, r1, d16
79 ; CHECK-NEXT: vmov r2, r3, d17
80 ; CHECK-NEXT: mov pc, lr
81 %tmp1 = load <4 x i32>, <4 x i32>* %A
82 %tmp2 = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %tmp1)
86 define <1 x i64> @vcnt64(<1 x i64>* %A) nounwind {
87 ; CHECK-LABEL: vcnt64:
89 ; CHECK-NEXT: vldr d16, [r0]
90 ; CHECK-NEXT: vcnt.8 d16, d16
91 ; CHECK-NEXT: vpaddl.u8 d16, d16
92 ; CHECK-NEXT: vpaddl.u16 d16, d16
93 ; CHECK-NEXT: vpaddl.u32 d16, d16
94 ; CHECK-NEXT: vmov r0, r1, d16
95 ; CHECK-NEXT: mov pc, lr
96 %tmp1 = load <1 x i64>, <1 x i64>* %A
97 %tmp2 = call <1 x i64> @llvm.ctpop.v1i64(<1 x i64> %tmp1)
101 define <2 x i64> @vcntQ64(<2 x i64>* %A) nounwind {
102 ; CHECK-LABEL: vcntQ64:
104 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
105 ; CHECK-NEXT: vcnt.8 q8, q8
106 ; CHECK-NEXT: vpaddl.u8 q8, q8
107 ; CHECK-NEXT: vpaddl.u16 q8, q8
108 ; CHECK-NEXT: vpaddl.u32 q8, q8
109 ; CHECK-NEXT: vmov r0, r1, d16
110 ; CHECK-NEXT: vmov r2, r3, d17
111 ; CHECK-NEXT: mov pc, lr
112 %tmp1 = load <2 x i64>, <2 x i64>* %A
113 %tmp2 = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %tmp1)
117 declare <8 x i8> @llvm.ctpop.v8i8(<8 x i8>) nounwind readnone
118 declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>) nounwind readnone
119 declare <4 x i16> @llvm.ctpop.v4i16(<4 x i16>) nounwind readnone
120 declare <8 x i16> @llvm.ctpop.v8i16(<8 x i16>) nounwind readnone
121 declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>) nounwind readnone
122 declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>) nounwind readnone
123 declare <1 x i64> @llvm.ctpop.v1i64(<1 x i64>) nounwind readnone
124 declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) nounwind readnone
126 define <8 x i8> @vclz8(<8 x i8>* %A) nounwind {
127 ; CHECK-LABEL: vclz8:
129 ; CHECK-NEXT: vldr d16, [r0]
130 ; CHECK-NEXT: vclz.i8 d16, d16
131 ; CHECK-NEXT: vmov r0, r1, d16
132 ; CHECK-NEXT: mov pc, lr
133 %tmp1 = load <8 x i8>, <8 x i8>* %A
134 %tmp2 = call <8 x i8> @llvm.ctlz.v8i8(<8 x i8> %tmp1, i1 0)
138 define <4 x i16> @vclz16(<4 x i16>* %A) nounwind {
139 ; CHECK-LABEL: vclz16:
141 ; CHECK-NEXT: vldr d16, [r0]
142 ; CHECK-NEXT: vclz.i16 d16, d16
143 ; CHECK-NEXT: vmov r0, r1, d16
144 ; CHECK-NEXT: mov pc, lr
145 %tmp1 = load <4 x i16>, <4 x i16>* %A
146 %tmp2 = call <4 x i16> @llvm.ctlz.v4i16(<4 x i16> %tmp1, i1 0)
150 define <2 x i32> @vclz32(<2 x i32>* %A) nounwind {
151 ; CHECK-LABEL: vclz32:
153 ; CHECK-NEXT: vldr d16, [r0]
154 ; CHECK-NEXT: vclz.i32 d16, d16
155 ; CHECK-NEXT: vmov r0, r1, d16
156 ; CHECK-NEXT: mov pc, lr
157 %tmp1 = load <2 x i32>, <2 x i32>* %A
158 %tmp2 = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %tmp1, i1 0)
162 define <16 x i8> @vclzQ8(<16 x i8>* %A) nounwind {
163 ; CHECK-LABEL: vclzQ8:
165 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
166 ; CHECK-NEXT: vclz.i8 q8, q8
167 ; CHECK-NEXT: vmov r0, r1, d16
168 ; CHECK-NEXT: vmov r2, r3, d17
169 ; CHECK-NEXT: mov pc, lr
170 %tmp1 = load <16 x i8>, <16 x i8>* %A
171 %tmp2 = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %tmp1, i1 0)
175 define <8 x i16> @vclzQ16(<8 x i16>* %A) nounwind {
176 ; CHECK-LABEL: vclzQ16:
178 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
179 ; CHECK-NEXT: vclz.i16 q8, q8
180 ; CHECK-NEXT: vmov r0, r1, d16
181 ; CHECK-NEXT: vmov r2, r3, d17
182 ; CHECK-NEXT: mov pc, lr
183 %tmp1 = load <8 x i16>, <8 x i16>* %A
184 %tmp2 = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %tmp1, i1 0)
188 define <4 x i32> @vclzQ32(<4 x i32>* %A) nounwind {
189 ; CHECK-LABEL: vclzQ32:
191 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
192 ; CHECK-NEXT: vclz.i32 q8, q8
193 ; CHECK-NEXT: vmov r0, r1, d16
194 ; CHECK-NEXT: vmov r2, r3, d17
195 ; CHECK-NEXT: mov pc, lr
196 %tmp1 = load <4 x i32>, <4 x i32>* %A
197 %tmp2 = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %tmp1, i1 0)
201 declare <8 x i8> @llvm.ctlz.v8i8(<8 x i8>, i1) nounwind readnone
202 declare <4 x i16> @llvm.ctlz.v4i16(<4 x i16>, i1) nounwind readnone
203 declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1) nounwind readnone
205 declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1) nounwind readnone
206 declare <8 x i16> @llvm.ctlz.v8i16(<8 x i16>, i1) nounwind readnone
207 declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1) nounwind readnone
209 define <8 x i8> @vclss8(<8 x i8>* %A) nounwind {
210 ; CHECK-LABEL: vclss8:
212 ; CHECK-NEXT: vldr d16, [r0]
213 ; CHECK-NEXT: vcls.s8 d16, d16
214 ; CHECK-NEXT: vmov r0, r1, d16
215 ; CHECK-NEXT: mov pc, lr
216 %tmp1 = load <8 x i8>, <8 x i8>* %A
217 %tmp2 = call <8 x i8> @llvm.arm.neon.vcls.v8i8(<8 x i8> %tmp1)
221 define <4 x i16> @vclss16(<4 x i16>* %A) nounwind {
222 ; CHECK-LABEL: vclss16:
224 ; CHECK-NEXT: vldr d16, [r0]
225 ; CHECK-NEXT: vcls.s16 d16, d16
226 ; CHECK-NEXT: vmov r0, r1, d16
227 ; CHECK-NEXT: mov pc, lr
228 %tmp1 = load <4 x i16>, <4 x i16>* %A
229 %tmp2 = call <4 x i16> @llvm.arm.neon.vcls.v4i16(<4 x i16> %tmp1)
233 define <2 x i32> @vclss32(<2 x i32>* %A) nounwind {
234 ; CHECK-LABEL: vclss32:
236 ; CHECK-NEXT: vldr d16, [r0]
237 ; CHECK-NEXT: vcls.s32 d16, d16
238 ; CHECK-NEXT: vmov r0, r1, d16
239 ; CHECK-NEXT: mov pc, lr
240 %tmp1 = load <2 x i32>, <2 x i32>* %A
241 %tmp2 = call <2 x i32> @llvm.arm.neon.vcls.v2i32(<2 x i32> %tmp1)
245 define <16 x i8> @vclsQs8(<16 x i8>* %A) nounwind {
246 ; CHECK-LABEL: vclsQs8:
248 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
249 ; CHECK-NEXT: vcls.s8 q8, q8
250 ; CHECK-NEXT: vmov r0, r1, d16
251 ; CHECK-NEXT: vmov r2, r3, d17
252 ; CHECK-NEXT: mov pc, lr
253 %tmp1 = load <16 x i8>, <16 x i8>* %A
254 %tmp2 = call <16 x i8> @llvm.arm.neon.vcls.v16i8(<16 x i8> %tmp1)
258 define <8 x i16> @vclsQs16(<8 x i16>* %A) nounwind {
259 ; CHECK-LABEL: vclsQs16:
261 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
262 ; CHECK-NEXT: vcls.s16 q8, q8
263 ; CHECK-NEXT: vmov r0, r1, d16
264 ; CHECK-NEXT: vmov r2, r3, d17
265 ; CHECK-NEXT: mov pc, lr
266 %tmp1 = load <8 x i16>, <8 x i16>* %A
267 %tmp2 = call <8 x i16> @llvm.arm.neon.vcls.v8i16(<8 x i16> %tmp1)
271 define <4 x i32> @vclsQs32(<4 x i32>* %A) nounwind {
272 ; CHECK-LABEL: vclsQs32:
274 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
275 ; CHECK-NEXT: vcls.s32 q8, q8
276 ; CHECK-NEXT: vmov r0, r1, d16
277 ; CHECK-NEXT: vmov r2, r3, d17
278 ; CHECK-NEXT: mov pc, lr
279 %tmp1 = load <4 x i32>, <4 x i32>* %A
280 %tmp2 = call <4 x i32> @llvm.arm.neon.vcls.v4i32(<4 x i32> %tmp1)
284 define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
285 ; CHECK-LABEL: ctpop_eq_one:
287 ; CHECK-NEXT: subs r2, r0, #1
288 ; CHECK-NEXT: sbc r3, r1, #0
289 ; CHECK-NEXT: and r2, r0, r2
290 ; CHECK-NEXT: and r3, r1, r3
291 ; CHECK-NEXT: orr r2, r2, r3
292 ; CHECK-NEXT: rsbs r3, r2, #0
293 ; CHECK-NEXT: adc r2, r2, r3
294 ; CHECK-NEXT: orrs r0, r0, r1
295 ; CHECK-NEXT: movne r0, #1
296 ; CHECK-NEXT: and r0, r0, r2
297 ; CHECK-NEXT: mov pc, lr
298 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
299 %cmp = icmp eq i64 %count, 1
300 %conv = zext i1 %cmp to i32
304 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
306 declare <8 x i8> @llvm.arm.neon.vcls.v8i8(<8 x i8>) nounwind readnone
307 declare <4 x i16> @llvm.arm.neon.vcls.v4i16(<4 x i16>) nounwind readnone
308 declare <2 x i32> @llvm.arm.neon.vcls.v2i32(<2 x i32>) nounwind readnone
310 declare <16 x i8> @llvm.arm.neon.vcls.v16i8(<16 x i8>) nounwind readnone
311 declare <8 x i16> @llvm.arm.neon.vcls.v8i16(<8 x i16>) nounwind readnone
312 declare <4 x i32> @llvm.arm.neon.vcls.v4i32(<4 x i32>) nounwind readnone