1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s --check-prefixes=CHECK,GENERIC
3 ; RUN: llc < %s -O0 -fast-isel -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s --check-prefixes=CHECK,FAST
4 ; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* \
5 ; RUN: -mtriple=arm64-eabi -aarch64-neon-syntax=apple \
6 ; RUN: | FileCheck %s --check-prefixes=GISEL,FALLBACK
8 ; FALLBACK-NOT: remark{{.*}}G_FPEXT{{.*}}(in function: test_vcvt_f64_f32)
9 ; FALLBACK-NOT: remark{{.*}}fpext{{.*}}(in function: test_vcvt_f64_f32)
10 define <2 x double> @test_vcvt_f64_f32(<2 x float> %x) nounwind readnone ssp {
11 ; CHECK-LABEL: test_vcvt_f64_f32:
13 ; CHECK-NEXT: fcvtl v0.2d, v0.2s
16 ; GISEL-LABEL: test_vcvt_f64_f32:
18 ; GISEL-NEXT: fcvtl v0.2d, v0.2s
20 %vcvt1.i = fpext <2 x float> %x to <2 x double>
21 ret <2 x double> %vcvt1.i
24 ; FALLBACK-NOT: remark{{.*}}G_FPEXT{{.*}}(in function: test_vcvt_high_f64_f32)
25 ; FALLBACK-NOT: remark{{.*}}fpext{{.*}}(in function: test_vcvt_high_f64_f32)
26 define <2 x double> @test_vcvt_high_f64_f32(<4 x float> %x) nounwind readnone ssp {
27 ; CHECK-LABEL: test_vcvt_high_f64_f32:
29 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
32 ; GISEL-LABEL: test_vcvt_high_f64_f32:
34 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
36 %cvt_in = shufflevector <4 x float> %x, <4 x float> undef, <2 x i32> <i32 2, i32 3>
37 %vcvt1.i = fpext <2 x float> %cvt_in to <2 x double>
38 ret <2 x double> %vcvt1.i
41 define <2 x double> @test_vcvt_high_v1f64_f32_bitcast(<4 x float> %x) nounwind readnone ssp {
42 ; CHECK-LABEL: test_vcvt_high_v1f64_f32_bitcast:
44 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
47 ; GISEL-LABEL: test_vcvt_high_v1f64_f32_bitcast:
49 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
51 %bc1 = bitcast <4 x float> %x to <2 x double>
52 %ext = shufflevector <2 x double> %bc1, <2 x double> undef, <1 x i32> <i32 1>
53 %bc2 = bitcast <1 x double> %ext to <2 x float>
54 %r = fpext <2 x float> %bc2 to <2 x double>
58 define <2 x double> @test_vcvt_high_v1i64_f32_bitcast(<2 x i64> %x) nounwind readnone ssp {
59 ; CHECK-LABEL: test_vcvt_high_v1i64_f32_bitcast:
61 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
64 ; GISEL-LABEL: test_vcvt_high_v1i64_f32_bitcast:
66 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
68 %ext = shufflevector <2 x i64> %x, <2 x i64> undef, <1 x i32> <i32 1>
69 %bc2 = bitcast <1 x i64> %ext to <2 x float>
70 %r = fpext <2 x float> %bc2 to <2 x double>
74 define <2 x double> @test_vcvt_high_v2i32_f32_bitcast(<4 x i32> %x) nounwind readnone ssp {
75 ; CHECK-LABEL: test_vcvt_high_v2i32_f32_bitcast:
77 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
80 ; GISEL-LABEL: test_vcvt_high_v2i32_f32_bitcast:
82 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
84 %ext = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 2, i32 3>
85 %bc2 = bitcast <2 x i32> %ext to <2 x float>
86 %r = fpext <2 x float> %bc2 to <2 x double>
90 define <2 x double> @test_vcvt_high_v4i16_f32_bitcast(<8 x i16> %x) nounwind readnone ssp {
91 ; CHECK-LABEL: test_vcvt_high_v4i16_f32_bitcast:
93 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
96 ; GISEL-LABEL: test_vcvt_high_v4i16_f32_bitcast:
98 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
100 %ext = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
101 %bc2 = bitcast <4 x i16> %ext to <2 x float>
102 %r = fpext <2 x float> %bc2 to <2 x double>
106 define <2 x double> @test_vcvt_high_v8i8_f32_bitcast(<16 x i8> %x) nounwind readnone ssp {
107 ; CHECK-LABEL: test_vcvt_high_v8i8_f32_bitcast:
109 ; CHECK-NEXT: fcvtl2 v0.2d, v0.4s
112 ; GISEL-LABEL: test_vcvt_high_v8i8_f32_bitcast:
114 ; GISEL-NEXT: fcvtl2 v0.2d, v0.4s
116 %ext = shufflevector <16 x i8> %x, <16 x i8> undef, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
117 %bc2 = bitcast <8 x i8> %ext to <2 x float>
118 %r = fpext <2 x float> %bc2 to <2 x double>
122 define <4 x float> @test_vcvt_high_v1i64_f16_bitcast(<2 x i64> %x) nounwind readnone ssp {
123 ; CHECK-LABEL: test_vcvt_high_v1i64_f16_bitcast:
125 ; CHECK-NEXT: fcvtl2 v0.4s, v0.8h
128 ; GISEL-LABEL: test_vcvt_high_v1i64_f16_bitcast:
130 ; GISEL-NEXT: fcvtl2 v0.4s, v0.8h
132 %ext = shufflevector <2 x i64> %x, <2 x i64> undef, <1 x i32> <i32 1>
133 %bc2 = bitcast <1 x i64> %ext to <4 x half>
134 %r = fpext <4 x half> %bc2 to <4 x float>
138 define <4 x float> @test_vcvt_high_v2i32_f16_bitcast(<4 x i32> %x) nounwind readnone ssp {
139 ; CHECK-LABEL: test_vcvt_high_v2i32_f16_bitcast:
141 ; CHECK-NEXT: fcvtl2 v0.4s, v0.8h
144 ; GISEL-LABEL: test_vcvt_high_v2i32_f16_bitcast:
146 ; GISEL-NEXT: fcvtl2 v0.4s, v0.8h
148 %ext = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 2, i32 3>
149 %bc2 = bitcast <2 x i32> %ext to <4 x half>
150 %r = fpext <4 x half> %bc2 to <4 x float>
154 define <4 x float> @test_vcvt_high_v4i16_f16_bitcast(<8 x i16> %x) nounwind readnone ssp {
155 ; CHECK-LABEL: test_vcvt_high_v4i16_f16_bitcast:
157 ; CHECK-NEXT: fcvtl2 v0.4s, v0.8h
160 ; GISEL-LABEL: test_vcvt_high_v4i16_f16_bitcast:
162 ; GISEL-NEXT: fcvtl2 v0.4s, v0.8h
164 %ext = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
165 %bc2 = bitcast <4 x i16> %ext to <4 x half>
166 %r = fpext <4 x half> %bc2 to <4 x float>
170 define <4 x float> @test_vcvt_high_v8i8_f16_bitcast(<16 x i8> %x) nounwind readnone ssp {
171 ; CHECK-LABEL: test_vcvt_high_v8i8_f16_bitcast:
173 ; CHECK-NEXT: fcvtl2 v0.4s, v0.8h
176 ; GISEL-LABEL: test_vcvt_high_v8i8_f16_bitcast:
178 ; GISEL-NEXT: fcvtl2 v0.4s, v0.8h
180 %ext = shufflevector <16 x i8> %x, <16 x i8> undef, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
181 %bc2 = bitcast <8 x i8> %ext to <4 x half>
182 %r = fpext <4 x half> %bc2 to <4 x float>
186 ; FALLBACK-NOT: remark{{.*}}G_FPEXT{{.*}}(in function: test_vcvt_f32_f64)
187 ; FALLBACK-NOT: remark{{.*}}fpext{{.*}}(in function: test_vcvt_f32_f64)
188 define <2 x float> @test_vcvt_f32_f64(<2 x double> %v) nounwind readnone ssp {
189 ; CHECK-LABEL: test_vcvt_f32_f64:
191 ; CHECK-NEXT: fcvtn v0.2s, v0.2d
194 ; GISEL-LABEL: test_vcvt_f32_f64:
196 ; GISEL-NEXT: fcvtn v0.2s, v0.2d
198 %vcvt1.i = fptrunc <2 x double> %v to <2 x float>
199 ret <2 x float> %vcvt1.i
202 define half @test_vcvt_f16_f32(<1 x float> %x) {
203 ; GENERIC-LABEL: test_vcvt_f16_f32:
205 ; GENERIC-NEXT: // kill: def $d0 killed $d0 def $q0
206 ; GENERIC-NEXT: fcvt h0, s0
209 ; FAST-LABEL: test_vcvt_f16_f32:
211 ; FAST-NEXT: fmov d1, d0
212 ; FAST-NEXT: // implicit-def: $q0
213 ; FAST-NEXT: fmov d0, d1
214 ; FAST-NEXT: // kill: def $s0 killed $s0 killed $q0
215 ; FAST-NEXT: fcvt h0, s0
218 ; GISEL-LABEL: test_vcvt_f16_f32:
220 ; GISEL-NEXT: fmov x8, d0
221 ; GISEL-NEXT: fmov s0, w8
222 ; GISEL-NEXT: fcvt h0, s0
224 %tmp = fptrunc <1 x float> %x to <1 x half>
225 %elt = extractelement <1 x half> %tmp, i32 0
229 ; FALLBACK-NOT: remark{{.*}}G_FPEXT{{.*}}(in function: test_vcvt_high_f32_f64)
230 ; FALLBACK-NOT: remark{{.*}}fpext{{.*}}(in function: test_vcvt_high_f32_f64)
231 define <4 x float> @test_vcvt_high_f32_f64(<2 x float> %x, <2 x double> %v) nounwind readnone ssp {
232 ; GENERIC-LABEL: test_vcvt_high_f32_f64:
234 ; GENERIC-NEXT: // kill: def $d0 killed $d0 def $q0
235 ; GENERIC-NEXT: fcvtn2 v0.4s, v1.2d
238 ; FAST-LABEL: test_vcvt_high_f32_f64:
240 ; FAST-NEXT: fmov d2, d0
241 ; FAST-NEXT: // implicit-def: $q0
242 ; FAST-NEXT: fmov d0, d2
243 ; FAST-NEXT: fcvtn2 v0.4s, v1.2d
246 ; GISEL-LABEL: test_vcvt_high_f32_f64:
248 ; GISEL-NEXT: // kill: def $d0 killed $d0 def $q0
249 ; GISEL-NEXT: fcvtn2 v0.4s, v1.2d
251 %cvt = fptrunc <2 x double> %v to <2 x float>
252 %vcvt2.i = shufflevector <2 x float> %x, <2 x float> %cvt, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
253 ret <4 x float> %vcvt2.i
256 define <2 x float> @test_vcvtx_f32_f64(<2 x double> %v) nounwind readnone ssp {
257 ; CHECK-LABEL: test_vcvtx_f32_f64:
259 ; CHECK-NEXT: fcvtxn v0.2s, v0.2d
262 ; GISEL-LABEL: test_vcvtx_f32_f64:
264 ; GISEL-NEXT: fcvtxn v0.2s, v0.2d
266 %vcvtx1.i = tail call <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double> %v) nounwind
267 ret <2 x float> %vcvtx1.i
270 define <4 x float> @test_vcvtx_high_f32_f64(<2 x float> %x, <2 x double> %v) nounwind readnone ssp {
271 ; GENERIC-LABEL: test_vcvtx_high_f32_f64:
273 ; GENERIC-NEXT: // kill: def $d0 killed $d0 def $q0
274 ; GENERIC-NEXT: fcvtxn2 v0.4s, v1.2d
277 ; FAST-LABEL: test_vcvtx_high_f32_f64:
279 ; FAST-NEXT: fmov d2, d0
280 ; FAST-NEXT: // implicit-def: $q0
281 ; FAST-NEXT: fmov d0, d2
282 ; FAST-NEXT: fcvtxn2 v0.4s, v1.2d
285 ; GISEL-LABEL: test_vcvtx_high_f32_f64:
287 ; GISEL-NEXT: // kill: def $d0 killed $d0 def $q0
288 ; GISEL-NEXT: fcvtxn2 v0.4s, v1.2d
290 %vcvtx2.i = tail call <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double> %v) nounwind
291 %res = shufflevector <2 x float> %x, <2 x float> %vcvtx2.i, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
296 declare <2 x double> @llvm.aarch64.neon.vcvthighfp2df(<4 x float>) nounwind readnone
297 declare <2 x double> @llvm.aarch64.neon.vcvtfp2df(<2 x float>) nounwind readnone
299 declare <2 x float> @llvm.aarch64.neon.vcvtdf2fp(<2 x double>) nounwind readnone
300 declare <4 x float> @llvm.aarch64.neon.vcvthighdf2fp(<2 x float>, <2 x double>) nounwind readnone
302 declare <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double>) nounwind readnone
304 define i16 @to_half(float %in) {
305 ; GENERIC-LABEL: to_half:
307 ; GENERIC-NEXT: fcvt h0, s0
308 ; GENERIC-NEXT: fmov w0, s0
311 ; FAST-LABEL: to_half:
313 ; FAST-NEXT: fcvt h1, s0
314 ; FAST-NEXT: // implicit-def: $w0
315 ; FAST-NEXT: fmov s0, w0
316 ; FAST-NEXT: fmov s0, s1
317 ; FAST-NEXT: fmov w0, s0
318 ; FAST-NEXT: // kill: def $w1 killed $w0
321 ; GISEL-LABEL: to_half:
323 ; GISEL-NEXT: fcvt h0, s0
324 ; GISEL-NEXT: fmov w0, s0
326 %res = call i16 @llvm.convert.to.fp16.f32(float %in)
330 define float @from_half(i16 %in) {
331 ; GENERIC-LABEL: from_half:
333 ; GENERIC-NEXT: fmov s0, w0
334 ; GENERIC-NEXT: fcvt s0, h0
337 ; FAST-LABEL: from_half:
339 ; FAST-NEXT: fmov s0, w0
340 ; FAST-NEXT: // kill: def $h0 killed $h0 killed $s0
341 ; FAST-NEXT: fcvt s0, h0
344 ; GISEL-LABEL: from_half:
346 ; GISEL-NEXT: fmov s0, w0
347 ; GISEL-NEXT: fcvt s0, h0
349 %res = call float @llvm.convert.from.fp16.f32(i16 %in)
353 declare float @llvm.convert.from.fp16.f32(i16) #1
354 declare i16 @llvm.convert.to.fp16.f32(float) #1