xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/fp16-promote.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -asm-verbose=false -mtriple=mipsel-linux-gnueabi -relocation-model=pic < %s | FileCheck %s -check-prefix=CHECK-LIBCALL
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_fadd:
4*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
5*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
6*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-DAG: add.s
7*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-DAG: %call16(__gnu_f2h_ieee)
8*9880d681SAndroid Build Coastguard Workerdefine void @test_fadd(half* %p, half* %q) #0 {
9*9880d681SAndroid Build Coastguard Worker  %a = load half, half* %p, align 2
10*9880d681SAndroid Build Coastguard Worker  %b = load half, half* %q, align 2
11*9880d681SAndroid Build Coastguard Worker  %r = fadd half %a, %b
12*9880d681SAndroid Build Coastguard Worker  store half %r, half* %p
13*9880d681SAndroid Build Coastguard Worker  ret void
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_fpext_float:
17*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
18*9880d681SAndroid Build Coastguard Workerdefine float @test_fpext_float(half* %p) {
19*9880d681SAndroid Build Coastguard Worker  %a = load half, half* %p, align 2
20*9880d681SAndroid Build Coastguard Worker  %r = fpext half %a to float
21*9880d681SAndroid Build Coastguard Worker  ret float %r
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_fpext_double:
25*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
26*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: cvt.d.s
27*9880d681SAndroid Build Coastguard Workerdefine double @test_fpext_double(half* %p) {
28*9880d681SAndroid Build Coastguard Worker  %a = load half, half* %p, align 2
29*9880d681SAndroid Build Coastguard Worker  %r = fpext half %a to double
30*9880d681SAndroid Build Coastguard Worker  ret double %r
31*9880d681SAndroid Build Coastguard Worker}
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_fptrunc_float:
34*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_f2h_ieee)
35*9880d681SAndroid Build Coastguard Workerdefine void @test_fptrunc_float(float %f, half* %p) #0 {
36*9880d681SAndroid Build Coastguard Worker  %a = fptrunc float %f to half
37*9880d681SAndroid Build Coastguard Worker  store half %a, half* %p
38*9880d681SAndroid Build Coastguard Worker  ret void
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_fptrunc_double:
42*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__truncdfhf2)
43*9880d681SAndroid Build Coastguard Workerdefine void @test_fptrunc_double(double %d, half* %p) #0 {
44*9880d681SAndroid Build Coastguard Worker  %a = fptrunc double %d to half
45*9880d681SAndroid Build Coastguard Worker  store half %a, half* %p
46*9880d681SAndroid Build Coastguard Worker  ret void
47*9880d681SAndroid Build Coastguard Worker}
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_vec_fpext_float:
50*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
51*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
52*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
53*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
54*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @test_vec_fpext_float(<4 x half>* %p) #0 {
55*9880d681SAndroid Build Coastguard Worker  %a = load <4 x half>, <4 x half>* %p, align 8
56*9880d681SAndroid Build Coastguard Worker  %b = fpext <4 x half> %a to <4 x float>
57*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %b
58*9880d681SAndroid Build Coastguard Worker}
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; This test is not robust against variations in instruction scheduling.
61*9880d681SAndroid Build Coastguard Worker; See the discussion in http://reviews.llvm.org/D8804
62*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_vec_fpext_double:
63*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
64*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
65*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
66*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: cvt.d.s
67*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: cvt.d.s
68*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: cvt.d.s
69*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
70*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: cvt.d.s
71*9880d681SAndroid Build Coastguard Workerdefine <4 x double> @test_vec_fpext_double(<4 x half>* %p) #0 {
72*9880d681SAndroid Build Coastguard Worker  %a = load <4 x half>, <4 x half>* %p, align 8
73*9880d681SAndroid Build Coastguard Worker  %b = fpext <4 x half> %a to <4 x double>
74*9880d681SAndroid Build Coastguard Worker  ret <4 x double> %b
75*9880d681SAndroid Build Coastguard Worker}
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_vec_fptrunc_float:
78*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_f2h_ieee)
79*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_f2h_ieee)
80*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_f2h_ieee)
81*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__gnu_f2h_ieee)
82*9880d681SAndroid Build Coastguard Workerdefine void @test_vec_fptrunc_float(<4 x float> %a, <4 x half>* %p) #0 {
83*9880d681SAndroid Build Coastguard Worker  %b = fptrunc <4 x float> %a to <4 x half>
84*9880d681SAndroid Build Coastguard Worker  store <4 x half> %b, <4 x half>* %p, align 8
85*9880d681SAndroid Build Coastguard Worker  ret void
86*9880d681SAndroid Build Coastguard Worker}
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL-LABEL: test_vec_fptrunc_double:
89*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__truncdfhf2)
90*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__truncdfhf2)
91*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__truncdfhf2)
92*9880d681SAndroid Build Coastguard Worker; CHECK-LIBCALL: %call16(__truncdfhf2)
93*9880d681SAndroid Build Coastguard Workerdefine void @test_vec_fptrunc_double(<4 x double> %a, <4 x half>* %p) #0 {
94*9880d681SAndroid Build Coastguard Worker  %b = fptrunc <4 x double> %a to <4 x half>
95*9880d681SAndroid Build Coastguard Worker  store <4 x half> %b, <4 x half>* %p, align 8
96*9880d681SAndroid Build Coastguard Worker  ret void
97*9880d681SAndroid Build Coastguard Worker}
98*9880d681SAndroid Build Coastguard Worker
99