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