1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=arm-eabi -mattr=+neon,+fp16 %s -o - | FileCheck %s
4 define <2 x i32> @vcvt_f32tos32(<2 x float>* %A) nounwind {
5 ; CHECK-LABEL: vcvt_f32tos32:
7 ; CHECK-NEXT: vldr d16, [r0]
8 ; CHECK-NEXT: vcvt.s32.f32 d16, d16
9 ; CHECK-NEXT: vmov r0, r1, d16
10 ; CHECK-NEXT: mov pc, lr
11 %tmp1 = load <2 x float>, <2 x float>* %A
12 %tmp2 = fptosi <2 x float> %tmp1 to <2 x i32>
16 define <2 x i32> @vcvt_f32tou32(<2 x float>* %A) nounwind {
17 ; CHECK-LABEL: vcvt_f32tou32:
19 ; CHECK-NEXT: vldr d16, [r0]
20 ; CHECK-NEXT: vcvt.u32.f32 d16, d16
21 ; CHECK-NEXT: vmov r0, r1, d16
22 ; CHECK-NEXT: mov pc, lr
23 %tmp1 = load <2 x float>, <2 x float>* %A
24 %tmp2 = fptoui <2 x float> %tmp1 to <2 x i32>
28 define <2 x float> @vcvt_s32tof32(<2 x i32>* %A) nounwind {
29 ; CHECK-LABEL: vcvt_s32tof32:
31 ; CHECK-NEXT: vldr d16, [r0]
32 ; CHECK-NEXT: vcvt.f32.s32 d16, d16
33 ; CHECK-NEXT: vmov r0, r1, d16
34 ; CHECK-NEXT: mov pc, lr
35 %tmp1 = load <2 x i32>, <2 x i32>* %A
36 %tmp2 = sitofp <2 x i32> %tmp1 to <2 x float>
40 define <2 x float> @vcvt_u32tof32(<2 x i32>* %A) nounwind {
41 ; CHECK-LABEL: vcvt_u32tof32:
43 ; CHECK-NEXT: vldr d16, [r0]
44 ; CHECK-NEXT: vcvt.f32.u32 d16, d16
45 ; CHECK-NEXT: vmov r0, r1, d16
46 ; CHECK-NEXT: mov pc, lr
47 %tmp1 = load <2 x i32>, <2 x i32>* %A
48 %tmp2 = uitofp <2 x i32> %tmp1 to <2 x float>
52 define <4 x i32> @vcvtQ_f32tos32(<4 x float>* %A) nounwind {
53 ; CHECK-LABEL: vcvtQ_f32tos32:
55 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
56 ; CHECK-NEXT: vcvt.s32.f32 q8, q8
57 ; CHECK-NEXT: vmov r0, r1, d16
58 ; CHECK-NEXT: vmov r2, r3, d17
59 ; CHECK-NEXT: mov pc, lr
60 %tmp1 = load <4 x float>, <4 x float>* %A
61 %tmp2 = fptosi <4 x float> %tmp1 to <4 x i32>
65 define <4 x i32> @vcvtQ_f32tou32(<4 x float>* %A) nounwind {
66 ; CHECK-LABEL: vcvtQ_f32tou32:
68 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
69 ; CHECK-NEXT: vcvt.u32.f32 q8, q8
70 ; CHECK-NEXT: vmov r0, r1, d16
71 ; CHECK-NEXT: vmov r2, r3, d17
72 ; CHECK-NEXT: mov pc, lr
73 %tmp1 = load <4 x float>, <4 x float>* %A
74 %tmp2 = fptoui <4 x float> %tmp1 to <4 x i32>
78 define <4 x float> @vcvtQ_s32tof32(<4 x i32>* %A) nounwind {
79 ; CHECK-LABEL: vcvtQ_s32tof32:
81 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
82 ; CHECK-NEXT: vcvt.f32.s32 q8, q8
83 ; CHECK-NEXT: vmov r0, r1, d16
84 ; CHECK-NEXT: vmov r2, r3, d17
85 ; CHECK-NEXT: mov pc, lr
86 %tmp1 = load <4 x i32>, <4 x i32>* %A
87 %tmp2 = sitofp <4 x i32> %tmp1 to <4 x float>
91 define <4 x float> @vcvtQ_u32tof32(<4 x i32>* %A) nounwind {
92 ; CHECK-LABEL: vcvtQ_u32tof32:
94 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
95 ; CHECK-NEXT: vcvt.f32.u32 q8, q8
96 ; CHECK-NEXT: vmov r0, r1, d16
97 ; CHECK-NEXT: vmov r2, r3, d17
98 ; CHECK-NEXT: mov pc, lr
99 %tmp1 = load <4 x i32>, <4 x i32>* %A
100 %tmp2 = uitofp <4 x i32> %tmp1 to <4 x float>
101 ret <4 x float> %tmp2
104 define <2 x i32> @vcvt_n_f32tos32(<2 x float>* %A) nounwind {
105 ; CHECK-LABEL: vcvt_n_f32tos32:
107 ; CHECK-NEXT: vldr d16, [r0]
108 ; CHECK-NEXT: vcvt.s32.f32 d16, d16, #1
109 ; CHECK-NEXT: vmov r0, r1, d16
110 ; CHECK-NEXT: mov pc, lr
111 %tmp1 = load <2 x float>, <2 x float>* %A
112 %tmp2 = call <2 x i32> @llvm.arm.neon.vcvtfp2fxs.v2i32.v2f32(<2 x float> %tmp1, i32 1)
116 define <2 x i32> @vcvt_n_f32tou32(<2 x float>* %A) nounwind {
117 ; CHECK-LABEL: vcvt_n_f32tou32:
119 ; CHECK-NEXT: vldr d16, [r0]
120 ; CHECK-NEXT: vcvt.u32.f32 d16, d16, #1
121 ; CHECK-NEXT: vmov r0, r1, d16
122 ; CHECK-NEXT: mov pc, lr
123 %tmp1 = load <2 x float>, <2 x float>* %A
124 %tmp2 = call <2 x i32> @llvm.arm.neon.vcvtfp2fxu.v2i32.v2f32(<2 x float> %tmp1, i32 1)
128 define <2 x float> @vcvt_n_s32tof32(<2 x i32>* %A) nounwind {
129 ; CHECK-LABEL: vcvt_n_s32tof32:
131 ; CHECK-NEXT: vldr d16, [r0]
132 ; CHECK-NEXT: vcvt.f32.s32 d16, d16, #1
133 ; CHECK-NEXT: vmov r0, r1, d16
134 ; CHECK-NEXT: mov pc, lr
135 %tmp1 = load <2 x i32>, <2 x i32>* %A
136 %tmp2 = call <2 x float> @llvm.arm.neon.vcvtfxs2fp.v2f32.v2i32(<2 x i32> %tmp1, i32 1)
137 ret <2 x float> %tmp2
140 define <2 x float> @vcvt_n_u32tof32(<2 x i32>* %A) nounwind {
141 ; CHECK-LABEL: vcvt_n_u32tof32:
143 ; CHECK-NEXT: vldr d16, [r0]
144 ; CHECK-NEXT: vcvt.f32.u32 d16, d16, #1
145 ; CHECK-NEXT: vmov r0, r1, d16
146 ; CHECK-NEXT: mov pc, lr
147 %tmp1 = load <2 x i32>, <2 x i32>* %A
148 %tmp2 = call <2 x float> @llvm.arm.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32> %tmp1, i32 1)
149 ret <2 x float> %tmp2
152 declare <2 x i32> @llvm.arm.neon.vcvtfp2fxs.v2i32.v2f32(<2 x float>, i32) nounwind readnone
153 declare <2 x i32> @llvm.arm.neon.vcvtfp2fxu.v2i32.v2f32(<2 x float>, i32) nounwind readnone
154 declare <2 x float> @llvm.arm.neon.vcvtfxs2fp.v2f32.v2i32(<2 x i32>, i32) nounwind readnone
155 declare <2 x float> @llvm.arm.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32>, i32) nounwind readnone
157 define <4 x i32> @vcvtQ_n_f32tos32(<4 x float>* %A) nounwind {
158 ; CHECK-LABEL: vcvtQ_n_f32tos32:
160 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
161 ; CHECK-NEXT: vcvt.s32.f32 q8, q8, #1
162 ; CHECK-NEXT: vmov r0, r1, d16
163 ; CHECK-NEXT: vmov r2, r3, d17
164 ; CHECK-NEXT: mov pc, lr
165 %tmp1 = load <4 x float>, <4 x float>* %A
166 %tmp2 = call <4 x i32> @llvm.arm.neon.vcvtfp2fxs.v4i32.v4f32(<4 x float> %tmp1, i32 1)
170 define <4 x i32> @vcvtQ_n_f32tou32(<4 x float>* %A) nounwind {
171 ; CHECK-LABEL: vcvtQ_n_f32tou32:
173 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
174 ; CHECK-NEXT: vcvt.u32.f32 q8, q8, #1
175 ; CHECK-NEXT: vmov r0, r1, d16
176 ; CHECK-NEXT: vmov r2, r3, d17
177 ; CHECK-NEXT: mov pc, lr
178 %tmp1 = load <4 x float>, <4 x float>* %A
179 %tmp2 = call <4 x i32> @llvm.arm.neon.vcvtfp2fxu.v4i32.v4f32(<4 x float> %tmp1, i32 1)
183 define <4 x float> @vcvtQ_n_s32tof32(<4 x i32>* %A) nounwind {
184 ; CHECK-LABEL: vcvtQ_n_s32tof32:
186 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
187 ; CHECK-NEXT: vcvt.f32.s32 q8, q8, #1
188 ; CHECK-NEXT: vmov r0, r1, d16
189 ; CHECK-NEXT: vmov r2, r3, d17
190 ; CHECK-NEXT: mov pc, lr
191 %tmp1 = load <4 x i32>, <4 x i32>* %A
192 %tmp2 = call <4 x float> @llvm.arm.neon.vcvtfxs2fp.v4f32.v4i32(<4 x i32> %tmp1, i32 1)
193 ret <4 x float> %tmp2
196 define <4 x float> @vcvtQ_n_u32tof32(<4 x i32>* %A) nounwind {
197 ; CHECK-LABEL: vcvtQ_n_u32tof32:
199 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
200 ; CHECK-NEXT: vcvt.f32.u32 q8, q8, #1
201 ; CHECK-NEXT: vmov r0, r1, d16
202 ; CHECK-NEXT: vmov r2, r3, d17
203 ; CHECK-NEXT: mov pc, lr
204 %tmp1 = load <4 x i32>, <4 x i32>* %A
205 %tmp2 = call <4 x float> @llvm.arm.neon.vcvtfxu2fp.v4f32.v4i32(<4 x i32> %tmp1, i32 1)
206 ret <4 x float> %tmp2
209 declare <4 x i32> @llvm.arm.neon.vcvtfp2fxs.v4i32.v4f32(<4 x float>, i32) nounwind readnone
210 declare <4 x i32> @llvm.arm.neon.vcvtfp2fxu.v4i32.v4f32(<4 x float>, i32) nounwind readnone
211 declare <4 x float> @llvm.arm.neon.vcvtfxs2fp.v4f32.v4i32(<4 x i32>, i32) nounwind readnone
212 declare <4 x float> @llvm.arm.neon.vcvtfxu2fp.v4f32.v4i32(<4 x i32>, i32) nounwind readnone
214 define <4 x float> @vcvt_f16tof32(<4 x i16>* %A) nounwind {
215 ; CHECK-LABEL: vcvt_f16tof32:
217 ; CHECK-NEXT: vldr d16, [r0]
218 ; CHECK-NEXT: vcvt.f32.f16 q8, d16
219 ; CHECK-NEXT: vmov r0, r1, d16
220 ; CHECK-NEXT: vmov r2, r3, d17
221 ; CHECK-NEXT: mov pc, lr
222 %tmp1 = load <4 x i16>, <4 x i16>* %A
223 %tmp2 = call <4 x float> @llvm.arm.neon.vcvthf2fp(<4 x i16> %tmp1)
224 ret <4 x float> %tmp2
227 define <4 x i16> @vcvt_f32tof16(<4 x float>* %A) nounwind {
228 ; CHECK-LABEL: vcvt_f32tof16:
230 ; CHECK-NEXT: vld1.64 {d16, d17}, [r0]
231 ; CHECK-NEXT: vcvt.f16.f32 d16, q8
232 ; CHECK-NEXT: vmov r0, r1, d16
233 ; CHECK-NEXT: mov pc, lr
234 %tmp1 = load <4 x float>, <4 x float>* %A
235 %tmp2 = call <4 x i16> @llvm.arm.neon.vcvtfp2hf(<4 x float> %tmp1)
239 declare <4 x float> @llvm.arm.neon.vcvthf2fp(<4 x i16>) nounwind readnone
240 declare <4 x i16> @llvm.arm.neon.vcvtfp2hf(<4 x float>) nounwind readnone
243 define <4 x i16> @fix_float_to_i16(<4 x float> %in) {
244 ; CHECK-LABEL: fix_float_to_i16:
246 ; CHECK-NEXT: vmov d17, r2, r3
247 ; CHECK-NEXT: vmov d16, r0, r1
248 ; CHECK-NEXT: vcvt.u32.f32 q8, q8, #1
249 ; CHECK-NEXT: vmovn.i32 d16, q8
250 ; CHECK-NEXT: vmov r0, r1, d16
251 ; CHECK-NEXT: mov pc, lr
253 %scale = fmul <4 x float> %in, <float 2.0, float 2.0, float 2.0, float 2.0>
254 %conv = fptoui <4 x float> %scale to <4 x i16>
258 define <2 x i64> @fix_float_to_i64(<2 x float> %in) {
259 ; CHECK-LABEL: fix_float_to_i64:
261 ; CHECK-NEXT: .save {r4, lr}
262 ; CHECK-NEXT: push {r4, lr}
263 ; CHECK-NEXT: .vsave {d8, d9}
264 ; CHECK-NEXT: vpush {d8, d9}
265 ; CHECK-NEXT: vmov d16, r0, r1
266 ; CHECK-NEXT: vadd.f32 d8, d16, d16
267 ; CHECK-NEXT: vmov r0, s17
268 ; CHECK-NEXT: bl __aeabi_f2ulz
269 ; CHECK-NEXT: mov r4, r1
270 ; CHECK-NEXT: vmov r1, s16
271 ; CHECK-NEXT: vmov.32 d9[0], r0
272 ; CHECK-NEXT: mov r0, r1
273 ; CHECK-NEXT: bl __aeabi_f2ulz
274 ; CHECK-NEXT: vmov.32 d8[0], r0
275 ; CHECK-NEXT: vmov.32 d9[1], r4
276 ; CHECK-NEXT: vmov.32 d8[1], r1
277 ; CHECK-NEXT: vmov r2, r3, d9
278 ; CHECK-NEXT: vmov r0, r1, d8
279 ; CHECK-NEXT: vpop {d8, d9}
280 ; CHECK-NEXT: pop {r4, lr}
281 ; CHECK-NEXT: mov pc, lr
283 %scale = fmul <2 x float> %in, <float 2.0, float 2.0>
284 %conv = fptoui <2 x float> %scale to <2 x i64>
288 define <4 x i16> @fix_double_to_i16(<4 x double> %in) {
289 ; CHECK-LABEL: fix_double_to_i16:
291 ; CHECK-NEXT: vmov d18, r0, r1
292 ; CHECK-NEXT: mov r12, sp
293 ; CHECK-NEXT: vld1.64 {d16, d17}, [r12]
294 ; CHECK-NEXT: vmov d19, r2, r3
295 ; CHECK-NEXT: vadd.f64 d18, d18, d18
296 ; CHECK-NEXT: vcvt.s32.f64 s0, d18
297 ; CHECK-NEXT: vmov r0, s0
298 ; CHECK-NEXT: vadd.f64 d20, d16, d16
299 ; CHECK-NEXT: vadd.f64 d19, d19, d19
300 ; CHECK-NEXT: vadd.f64 d16, d17, d17
301 ; CHECK-NEXT: vcvt.s32.f64 s2, d20
302 ; CHECK-NEXT: vcvt.s32.f64 s4, d19
303 ; CHECK-NEXT: vcvt.s32.f64 s6, d16
304 ; CHECK-NEXT: vmov.32 d16[0], r0
305 ; CHECK-NEXT: vmov r0, s2
306 ; CHECK-NEXT: vmov.32 d17[0], r0
307 ; CHECK-NEXT: vmov r0, s4
308 ; CHECK-NEXT: vmov.32 d16[1], r0
309 ; CHECK-NEXT: vmov r0, s6
310 ; CHECK-NEXT: vmov.32 d17[1], r0
311 ; CHECK-NEXT: vuzp.16 d16, d17
312 ; CHECK-NEXT: vmov r0, r1, d16
313 ; CHECK-NEXT: mov pc, lr
315 %scale = fmul <4 x double> %in, <double 2.0, double 2.0, double 2.0, double 2.0>
316 %conv = fptoui <4 x double> %scale to <4 x i16>
320 define <2 x i64> @fix_double_to_i64(<2 x double> %in) {
321 ; CHECK-LABEL: fix_double_to_i64:
323 ; CHECK-NEXT: .save {r4, lr}
324 ; CHECK-NEXT: push {r4, lr}
325 ; CHECK-NEXT: .vsave {d8, d9}
326 ; CHECK-NEXT: vpush {d8, d9}
327 ; CHECK-NEXT: vmov d16, r2, r3
328 ; CHECK-NEXT: vadd.f64 d16, d16, d16
329 ; CHECK-NEXT: vmov r2, r3, d16
330 ; CHECK-NEXT: vmov d16, r0, r1
331 ; CHECK-NEXT: vadd.f64 d8, d16, d16
332 ; CHECK-NEXT: mov r0, r2
333 ; CHECK-NEXT: mov r1, r3
334 ; CHECK-NEXT: bl __aeabi_d2ulz
335 ; CHECK-NEXT: mov r4, r1
336 ; CHECK-NEXT: vmov r2, r1, d8
337 ; CHECK-NEXT: vmov.32 d9[0], r0
338 ; CHECK-NEXT: mov r0, r2
339 ; CHECK-NEXT: bl __aeabi_d2ulz
340 ; CHECK-NEXT: vmov.32 d8[0], r0
341 ; CHECK-NEXT: vmov.32 d9[1], r4
342 ; CHECK-NEXT: vmov.32 d8[1], r1
343 ; CHECK-NEXT: vmov r2, r3, d9
344 ; CHECK-NEXT: vmov r0, r1, d8
345 ; CHECK-NEXT: vpop {d8, d9}
346 ; CHECK-NEXT: pop {r4, lr}
347 ; CHECK-NEXT: mov pc, lr
348 %scale = fmul <2 x double> %in, <double 2.0, double 2.0>
349 %conv = fptoui <2 x double> %scale to <2 x i64>
353 define i32 @multi_sint(double %c, i32* nocapture %p, i32* nocapture %q) {
354 ; CHECK-LABEL: multi_sint:
356 ; CHECK-NEXT: vmov d16, r0, r1
357 ; CHECK-NEXT: vcvt.s32.f64 s0, d16
358 ; CHECK-NEXT: vstr s0, [r2]
359 ; CHECK-NEXT: vcvt.s32.f64 s0, d16
360 ; CHECK-NEXT: vcvt.s32.f64 s2, d16
361 ; CHECK-NEXT: vmov r0, s2
362 ; CHECK-NEXT: vstr s0, [r3]
363 ; CHECK-NEXT: mov pc, lr
364 %conv = fptosi double %c to i32
365 store i32 %conv, i32* %p, align 4
366 store i32 %conv, i32* %q, align 4
370 define i32 @multi_uint(double %c, i32* nocapture %p, i32* nocapture %q) {
371 ; CHECK-LABEL: multi_uint:
373 ; CHECK-NEXT: vmov d16, r0, r1
374 ; CHECK-NEXT: vcvt.u32.f64 s0, d16
375 ; CHECK-NEXT: vstr s0, [r2]
376 ; CHECK-NEXT: vcvt.u32.f64 s0, d16
377 ; CHECK-NEXT: vcvt.u32.f64 s2, d16
378 ; CHECK-NEXT: vmov r0, s2
379 ; CHECK-NEXT: vstr s0, [r3]
380 ; CHECK-NEXT: mov pc, lr
381 %conv = fptoui double %c to i32
382 store i32 %conv, i32* %p, align 4
383 store i32 %conv, i32* %q, align 4
387 define void @double_to_sint_store(double %c, i32* nocapture %p) {
388 ; CHECK-LABEL: double_to_sint_store:
390 ; CHECK-NEXT: vmov d16, r0, r1
391 ; CHECK-NEXT: vcvt.s32.f64 s0, d16
392 ; CHECK-NEXT: vstr s0, [r2]
393 ; CHECK-NEXT: mov pc, lr
394 %conv = fptosi double %c to i32
395 store i32 %conv, i32* %p, align 4
399 define void @double_to_uint_store(double %c, i32* nocapture %p) {
400 ; CHECK-LABEL: double_to_uint_store:
402 ; CHECK-NEXT: vmov d16, r0, r1
403 ; CHECK-NEXT: vcvt.u32.f64 s0, d16
404 ; CHECK-NEXT: vstr s0, [r2]
405 ; CHECK-NEXT: mov pc, lr
406 %conv = fptoui double %c to i32
407 store i32 %conv, i32* %p, align 4
411 define void @float_to_sint_store(float %c, i32* nocapture %p) {
412 ; CHECK-LABEL: float_to_sint_store:
414 ; CHECK-NEXT: vmov s0, r0
415 ; CHECK-NEXT: vcvt.s32.f32 s0, s0
416 ; CHECK-NEXT: vstr s0, [r1]
417 ; CHECK-NEXT: mov pc, lr
418 %conv = fptosi float %c to i32
419 store i32 %conv, i32* %p, align 4
423 define void @float_to_uint_store(float %c, i32* nocapture %p) {
424 ; CHECK-LABEL: float_to_uint_store:
426 ; CHECK-NEXT: vmov s0, r0
427 ; CHECK-NEXT: vcvt.u32.f32 s0, s0
428 ; CHECK-NEXT: vstr s0, [r1]
429 ; CHECK-NEXT: mov pc, lr
430 %conv = fptoui float %c to i32
431 store i32 %conv, i32* %p, align 4