xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-vcvt_f.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=arm64 -aarch64-neon-syntax=apple | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -march=arm64 -aarch64-neon-syntax=apple | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine <2 x double> @test_vcvt_f64_f32(<2 x float> %x) nounwind readnone ssp {
5*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvt_f64_f32:
6*9880d681SAndroid Build Coastguard Worker  %vcvt1.i = fpext <2 x float> %x to <2 x double>
7*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtl	v0.2d, v0.2s
8*9880d681SAndroid Build Coastguard Worker  ret <2 x double> %vcvt1.i
9*9880d681SAndroid Build Coastguard Worker; CHECK: ret
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine <2 x double> @test_vcvt_high_f64_f32(<4 x float> %x) nounwind readnone ssp {
13*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvt_high_f64_f32:
14*9880d681SAndroid Build Coastguard Worker  %cvt_in = shufflevector <4 x float> %x, <4 x float> undef, <2 x i32> <i32 2, i32 3>
15*9880d681SAndroid Build Coastguard Worker  %vcvt1.i = fpext <2 x float> %cvt_in to <2 x double>
16*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtl2	v0.2d, v0.4s
17*9880d681SAndroid Build Coastguard Worker  ret <2 x double> %vcvt1.i
18*9880d681SAndroid Build Coastguard Worker; CHECK: ret
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vcvt_f32_f64(<2 x double> %v) nounwind readnone ssp {
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvt_f32_f64:
23*9880d681SAndroid Build Coastguard Worker  %vcvt1.i = fptrunc <2 x double> %v to <2 x float>
24*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtn
25*9880d681SAndroid Build Coastguard Worker  ret <2 x float> %vcvt1.i
26*9880d681SAndroid Build Coastguard Worker; CHECK: ret
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @test_vcvt_high_f32_f64(<2 x float> %x, <2 x double> %v) nounwind readnone ssp {
30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvt_high_f32_f64:
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker  %cvt = fptrunc <2 x double> %v to <2 x float>
33*9880d681SAndroid Build Coastguard Worker  %vcvt2.i = shufflevector <2 x float> %x, <2 x float> %cvt, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
34*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtn2
35*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %vcvt2.i
36*9880d681SAndroid Build Coastguard Worker; CHECK: ret
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vcvtx_f32_f64(<2 x double> %v) nounwind readnone ssp {
40*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvtx_f32_f64:
41*9880d681SAndroid Build Coastguard Worker  %vcvtx1.i = tail call <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double> %v) nounwind
42*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtxn
43*9880d681SAndroid Build Coastguard Worker  ret <2 x float> %vcvtx1.i
44*9880d681SAndroid Build Coastguard Worker; CHECK: ret
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @test_vcvtx_high_f32_f64(<2 x float> %x, <2 x double> %v) nounwind readnone ssp {
48*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vcvtx_high_f32_f64:
49*9880d681SAndroid Build Coastguard Worker  %vcvtx2.i = tail call <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double> %v) nounwind
50*9880d681SAndroid Build Coastguard Worker  %res = shufflevector <2 x float> %x, <2 x float> %vcvtx2.i, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
51*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtxn2
52*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %res
53*9880d681SAndroid Build Coastguard Worker; CHECK: ret
54*9880d681SAndroid Build Coastguard Worker}
55*9880d681SAndroid Build Coastguard Worker
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Workerdeclare <2 x double> @llvm.aarch64.neon.vcvthighfp2df(<4 x float>) nounwind readnone
58*9880d681SAndroid Build Coastguard Workerdeclare <2 x double> @llvm.aarch64.neon.vcvtfp2df(<2 x float>) nounwind readnone
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Workerdeclare <2 x float> @llvm.aarch64.neon.vcvtdf2fp(<2 x double>) nounwind readnone
61*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.aarch64.neon.vcvthighdf2fp(<2 x float>, <2 x double>) nounwind readnone
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Workerdeclare <2 x float> @llvm.aarch64.neon.fcvtxn.v2f32.v2f64(<2 x double>) nounwind readnone
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Workerdefine i16 @to_half(float %in) {
66*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: to_half:
67*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h[[HALFVAL:[0-9]+]], s0
68*9880d681SAndroid Build Coastguard Worker; CHECK: fmov {{w[0-9]+}}, {{s[0-9]+}}
69*9880d681SAndroid Build Coastguard Worker  %res = call i16 @llvm.convert.to.fp16.f32(float %in)
70*9880d681SAndroid Build Coastguard Worker  ret i16 %res
71*9880d681SAndroid Build Coastguard Worker}
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Workerdefine float @from_half(i16 %in) {
74*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: from_half:
75*9880d681SAndroid Build Coastguard Worker; CHECK: fmov {{s[0-9]+}}, {{w[0-9]+}}
76*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt s0, {{h[0-9]+}}
77*9880d681SAndroid Build Coastguard Worker  %res = call float @llvm.convert.from.fp16.f32(i16 %in)
78*9880d681SAndroid Build Coastguard Worker  ret float %res
79*9880d681SAndroid Build Coastguard Worker}
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.convert.from.fp16.f32(i16) #1
82*9880d681SAndroid Build Coastguard Workerdeclare i16 @llvm.convert.to.fp16.f32(float) #1
83