1 ; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
3 declare i16 @llvm.convert.to.fp16.f32(float %a)
4 declare i16 @llvm.convert.to.fp16.f64(double %a)
6 declare float @llvm.convert.from.fp16.f32(i16 %a)
7 declare double @llvm.convert.from.fp16.f64(i16 %a)
9 define float @func_i16fp32(i16* %a) {
10 ; CHECK-LABEL: func_i16fp32:
11 ; CHECK: .LBB{{[0-9]+}}_2:
12 ; CHECK-NEXT: ld2b.zx %s0, (, %s0)
13 ; CHECK-NEXT: lea %s1, __gnu_h2f_ieee@lo
14 ; CHECK-NEXT: and %s1, %s1, (32)0
15 ; CHECK-NEXT: lea.sl %s12, __gnu_h2f_ieee@hi(, %s1)
16 ; CHECK-NEXT: bsic %s10, (, %s12)
17 ; CHECK-NEXT: or %s11, 0, %s9
18 %a.val = load i16, i16* %a, align 4
19 %a.asd = call float @llvm.convert.from.fp16.f32(i16 %a.val)
23 define double @func_i16fp64(i16* %a) {
24 ; CHECK-LABEL: func_i16fp64:
25 ; CHECK: .LBB{{[0-9]+}}_2:
26 ; CHECK-NEXT: ld2b.zx %s0, (, %s0)
27 ; CHECK-NEXT: lea %s1, __gnu_h2f_ieee@lo
28 ; CHECK-NEXT: and %s1, %s1, (32)0
29 ; CHECK-NEXT: lea.sl %s12, __gnu_h2f_ieee@hi(, %s1)
30 ; CHECK-NEXT: bsic %s10, (, %s12)
31 ; CHECK-NEXT: cvt.d.s %s0, %s0
32 ; CHECK-NEXT: or %s11, 0, %s9
33 %a.val = load i16, i16* %a, align 4
34 %a.asd = call double @llvm.convert.from.fp16.f64(i16 %a.val)
38 define float @func_fp16fp32(half* %a) {
39 ; CHECK-LABEL: func_fp16fp32:
40 ; CHECK: .LBB{{[0-9]+}}_2:
41 ; CHECK-NEXT: ld2b.zx %s0, (, %s0)
42 ; CHECK-NEXT: lea %s1, __gnu_h2f_ieee@lo
43 ; CHECK-NEXT: and %s1, %s1, (32)0
44 ; CHECK-NEXT: lea.sl %s12, __gnu_h2f_ieee@hi(, %s1)
45 ; CHECK-NEXT: bsic %s10, (, %s12)
46 ; CHECK-NEXT: or %s11, 0, %s9
47 %a.val = load half, half* %a, align 4
48 %a.asd = fpext half %a.val to float
52 define double @func_fp16fp64(half* %a) {
53 ; CHECK-LABEL: func_fp16fp64:
54 ; CHECK: .LBB{{[0-9]+}}_2:
55 ; CHECK-NEXT: ld2b.zx %s0, (, %s0)
56 ; CHECK-NEXT: lea %s1, __gnu_h2f_ieee@lo
57 ; CHECK-NEXT: and %s1, %s1, (32)0
58 ; CHECK-NEXT: lea.sl %s12, __gnu_h2f_ieee@hi(, %s1)
59 ; CHECK-NEXT: bsic %s10, (, %s12)
60 ; CHECK-NEXT: cvt.d.s %s0, %s0
61 ; CHECK-NEXT: or %s11, 0, %s9
62 %a.val = load half, half* %a, align 4
63 %a.asd = fpext half %a.val to double
67 define void @func_fp32i16(i16* %fl.ptr, float %val) {
68 ; CHECK-LABEL: func_fp32i16:
69 ; CHECK: .LBB{{[0-9]+}}_2:
70 ; CHECK-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill
71 ; CHECK-NEXT: or %s18, 0, %s0
72 ; CHECK-NEXT: lea %s0, __gnu_f2h_ieee@lo
73 ; CHECK-NEXT: and %s0, %s0, (32)0
74 ; CHECK-NEXT: lea.sl %s12, __gnu_f2h_ieee@hi(, %s0)
75 ; CHECK-NEXT: or %s0, 0, %s1
76 ; CHECK-NEXT: bsic %s10, (, %s12)
77 ; CHECK-NEXT: st2b %s0, (, %s18)
78 ; CHECK-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload
79 ; CHECK-NEXT: or %s11, 0, %s9
80 %val.asf = call i16 @llvm.convert.to.fp16.f32(float %val)
81 store i16 %val.asf, i16* %fl.ptr
85 define half @func_fp32fp16(half* %fl.ptr, float %a) {
86 ; CHECK-LABEL: func_fp32fp16:
87 ; CHECK: .LBB{{[0-9]+}}_2:
88 ; CHECK-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill
89 ; CHECK-NEXT: st %s19, 296(, %s11) # 8-byte Folded Spill
90 ; CHECK-NEXT: or %s18, 0, %s0
91 ; CHECK-NEXT: lea %s0, __gnu_f2h_ieee@lo
92 ; CHECK-NEXT: and %s0, %s0, (32)0
93 ; CHECK-NEXT: lea.sl %s12, __gnu_f2h_ieee@hi(, %s0)
94 ; CHECK-NEXT: or %s0, 0, %s1
95 ; CHECK-NEXT: bsic %s10, (, %s12)
96 ; CHECK-NEXT: or %s19, 0, %s0
97 ; CHECK-NEXT: lea %s0, __gnu_h2f_ieee@lo
98 ; CHECK-NEXT: and %s0, %s0, (32)0
99 ; CHECK-NEXT: lea.sl %s12, __gnu_h2f_ieee@hi(, %s0)
100 ; CHECK-NEXT: or %s0, 0, %s19
101 ; CHECK-NEXT: bsic %s10, (, %s12)
102 ; CHECK-NEXT: st2b %s19, (, %s18)
103 ; CHECK-NEXT: ld %s19, 296(, %s11) # 8-byte Folded Reload
104 ; CHECK-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload
105 ; CHECK-NEXT: or %s11, 0, %s9
106 %a.asd = fptrunc float %a to half
107 store half %a.asd, half* %fl.ptr
111 define double @func_fp32fp64(float* %a) {
112 ; CHECK-LABEL: func_fp32fp64:
114 ; CHECK-NEXT: ldu %s0, (, %s0)
115 ; CHECK-NEXT: cvt.d.s %s0, %s0
116 ; CHECK-NEXT: b.l.t (, %s10)
117 %a.val = load float, float* %a, align 4
118 %a.asd = fpext float %a.val to double
122 define void @func_fp64i16(i16* %fl.ptr, double %val) {
123 ; CHECK-LABEL: func_fp64i16:
124 ; CHECK: .LBB{{[0-9]+}}_2:
125 ; CHECK-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill
126 ; CHECK-NEXT: or %s18, 0, %s0
127 ; CHECK-NEXT: lea %s0, __truncdfhf2@lo
128 ; CHECK-NEXT: and %s0, %s0, (32)0
129 ; CHECK-NEXT: lea.sl %s12, __truncdfhf2@hi(, %s0)
130 ; CHECK-NEXT: or %s0, 0, %s1
131 ; CHECK-NEXT: bsic %s10, (, %s12)
132 ; CHECK-NEXT: st2b %s0, (, %s18)
133 ; CHECK-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload
134 ; CHECK-NEXT: or %s11, 0, %s9
135 %val.asf = call i16 @llvm.convert.to.fp16.f64(double %val)
136 store i16 %val.asf, i16* %fl.ptr
140 define void @func_fp64fp16(half* %fl.ptr, double %val) {
141 ; CHECK-LABEL: func_fp64fp16:
142 ; CHECK: .LBB{{[0-9]+}}_2:
143 ; CHECK-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill
144 ; CHECK-NEXT: or %s18, 0, %s0
145 ; CHECK-NEXT: lea %s0, __truncdfhf2@lo
146 ; CHECK-NEXT: and %s0, %s0, (32)0
147 ; CHECK-NEXT: lea.sl %s12, __truncdfhf2@hi(, %s0)
148 ; CHECK-NEXT: or %s0, 0, %s1
149 ; CHECK-NEXT: bsic %s10, (, %s12)
150 ; CHECK-NEXT: st2b %s0, (, %s18)
151 ; CHECK-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload
152 ; CHECK-NEXT: or %s11, 0, %s9
153 %val.asf = fptrunc double %val to half
154 store half %val.asf, half* %fl.ptr
158 define void @func_fp64fp32(float* %fl.ptr, double %val) {
159 ; CHECK-LABEL: func_fp64fp32:
161 ; CHECK-NEXT: cvt.s.d %s1, %s1
162 ; CHECK-NEXT: stu %s1, (, %s0)
163 ; CHECK-NEXT: b.l.t (, %s10)
164 %val.asf = fptrunc double %val to float
165 store float %val.asf, float* %fl.ptr