1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+experimental-zfh \
3 ; RUN: -verify-machineinstrs -target-abi ilp32f | \
4 ; RUN: FileCheck -check-prefix=RV32IZFH %s
5 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+d \
6 ; RUN: -mattr=+experimental-zfh -verify-machineinstrs -target-abi ilp32d | \
7 ; RUN: FileCheck -check-prefix=RV32IDZFH %s
8 ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+experimental-zfh \
9 ; RUN: -verify-machineinstrs -target-abi lp64f | \
10 ; RUN: FileCheck -check-prefix=RV64IZFH %s
11 ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+d \
12 ; RUN: -mattr=+experimental-zfh -verify-machineinstrs -target-abi lp64d | \
13 ; RUN: FileCheck -check-prefix=RV64IDZFH %s
15 declare half @llvm.sqrt.f16(half)
17 define half @sqrt_f16(half %a) nounwind {
18 ; RV32IZFH-LABEL: sqrt_f16:
20 ; RV32IZFH-NEXT: fsqrt.h fa0, fa0
23 ; RV32IDZFH-LABEL: sqrt_f16:
25 ; RV32IDZFH-NEXT: fsqrt.h fa0, fa0
28 ; RV64IZFH-LABEL: sqrt_f16:
30 ; RV64IZFH-NEXT: fsqrt.h fa0, fa0
33 ; RV64IDZFH-LABEL: sqrt_f16:
35 ; RV64IDZFH-NEXT: fsqrt.h fa0, fa0
37 %1 = call half @llvm.sqrt.f16(half %a)
41 declare half @llvm.fma.f16(half, half, half)
43 define half @fma_f16(half %a, half %b, half %c) nounwind {
44 ; RV32IZFH-LABEL: fma_f16:
46 ; RV32IZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
49 ; RV32IDZFH-LABEL: fma_f16:
51 ; RV32IDZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
54 ; RV64IZFH-LABEL: fma_f16:
56 ; RV64IZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
59 ; RV64IDZFH-LABEL: fma_f16:
61 ; RV64IDZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
63 %1 = call half @llvm.fma.f16(half %a, half %b, half %c)
67 declare half @llvm.fmuladd.f16(half, half, half)
69 define half @fmuladd_f16(half %a, half %b, half %c) nounwind {
70 ; RV32IZFH-LABEL: fmuladd_f16:
72 ; RV32IZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
75 ; RV32IDZFH-LABEL: fmuladd_f16:
77 ; RV32IDZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
80 ; RV64IZFH-LABEL: fmuladd_f16:
82 ; RV64IZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
85 ; RV64IDZFH-LABEL: fmuladd_f16:
87 ; RV64IDZFH-NEXT: fmadd.h fa0, fa0, fa1, fa2
89 %1 = call half @llvm.fmuladd.f16(half %a, half %b, half %c)
93 declare half @llvm.fabs.f16(half)
95 define half @fabs_f16(half %a) nounwind {
96 ; RV32IZFH-LABEL: fabs_f16:
98 ; RV32IZFH-NEXT: fabs.h fa0, fa0
101 ; RV32IDZFH-LABEL: fabs_f16:
102 ; RV32IDZFH: # %bb.0:
103 ; RV32IDZFH-NEXT: fabs.h fa0, fa0
104 ; RV32IDZFH-NEXT: ret
106 ; RV64IZFH-LABEL: fabs_f16:
108 ; RV64IZFH-NEXT: fabs.h fa0, fa0
111 ; RV64IDZFH-LABEL: fabs_f16:
112 ; RV64IDZFH: # %bb.0:
113 ; RV64IDZFH-NEXT: fabs.h fa0, fa0
114 ; RV64IDZFH-NEXT: ret
115 %1 = call half @llvm.fabs.f16(half %a)
119 declare half @llvm.minnum.f16(half, half)
121 define half @minnum_f16(half %a, half %b) nounwind {
122 ; RV32IZFH-LABEL: minnum_f16:
124 ; RV32IZFH-NEXT: fmin.h fa0, fa0, fa1
127 ; RV32IDZFH-LABEL: minnum_f16:
128 ; RV32IDZFH: # %bb.0:
129 ; RV32IDZFH-NEXT: fmin.h fa0, fa0, fa1
130 ; RV32IDZFH-NEXT: ret
132 ; RV64IZFH-LABEL: minnum_f16:
134 ; RV64IZFH-NEXT: fmin.h fa0, fa0, fa1
137 ; RV64IDZFH-LABEL: minnum_f16:
138 ; RV64IDZFH: # %bb.0:
139 ; RV64IDZFH-NEXT: fmin.h fa0, fa0, fa1
140 ; RV64IDZFH-NEXT: ret
141 %1 = call half @llvm.minnum.f16(half %a, half %b)
145 declare half @llvm.maxnum.f16(half, half)
147 define half @maxnum_f16(half %a, half %b) nounwind {
148 ; RV32IZFH-LABEL: maxnum_f16:
150 ; RV32IZFH-NEXT: fmax.h fa0, fa0, fa1
153 ; RV32IDZFH-LABEL: maxnum_f16:
154 ; RV32IDZFH: # %bb.0:
155 ; RV32IDZFH-NEXT: fmax.h fa0, fa0, fa1
156 ; RV32IDZFH-NEXT: ret
158 ; RV64IZFH-LABEL: maxnum_f16:
160 ; RV64IZFH-NEXT: fmax.h fa0, fa0, fa1
163 ; RV64IDZFH-LABEL: maxnum_f16:
164 ; RV64IDZFH: # %bb.0:
165 ; RV64IDZFH-NEXT: fmax.h fa0, fa0, fa1
166 ; RV64IDZFH-NEXT: ret
167 %1 = call half @llvm.maxnum.f16(half %a, half %b)
171 declare half @llvm.copysign.f16(half, half)
173 define half @copysign_f16(half %a, half %b) nounwind {
174 ; RV32IZFH-LABEL: copysign_f16:
176 ; RV32IZFH-NEXT: fsgnj.h fa0, fa0, fa1
179 ; RV32IDZFH-LABEL: copysign_f16:
180 ; RV32IDZFH: # %bb.0:
181 ; RV32IDZFH-NEXT: fsgnj.h fa0, fa0, fa1
182 ; RV32IDZFH-NEXT: ret
184 ; RV64IZFH-LABEL: copysign_f16:
186 ; RV64IZFH-NEXT: fsgnj.h fa0, fa0, fa1
189 ; RV64IDZFH-LABEL: copysign_f16:
190 ; RV64IDZFH: # %bb.0:
191 ; RV64IDZFH-NEXT: fsgnj.h fa0, fa0, fa1
192 ; RV64IDZFH-NEXT: ret
193 %1 = call half @llvm.copysign.f16(half %a, half %b)
197 declare iXLen @llvm.lrint.iXLen.f16(float)
199 define iXLen @lrint_f16(float %a) nounwind {
200 ; RV32IZFH-LABEL: lrint_f16:
202 ; RV32IZFH-NEXT: fcvt.w.s a0, fa0
205 ; RV32IDZFH-LABEL: lrint_f16:
206 ; RV32IDZFH: # %bb.0:
207 ; RV32IDZFH-NEXT: fcvt.w.s a0, fa0
208 ; RV32IDZFH-NEXT: ret
210 ; RV64IZFH-LABEL: lrint_f16:
212 ; RV64IZFH-NEXT: fcvt.l.s a0, fa0
215 ; RV64IDZFH-LABEL: lrint_f16:
216 ; RV64IDZFH: # %bb.0:
217 ; RV64IDZFH-NEXT: fcvt.l.s a0, fa0
218 ; RV64IDZFH-NEXT: ret
219 %1 = call iXLen @llvm.lrint.iXLen.f16(float %a)
223 declare iXLen @llvm.lround.iXLen.f16(float)
225 define iXLen @lround_f16(float %a) nounwind {
226 ; RV32IZFH-LABEL: lround_f16:
228 ; RV32IZFH-NEXT: fcvt.w.s a0, fa0, rmm
231 ; RV32IDZFH-LABEL: lround_f16:
232 ; RV32IDZFH: # %bb.0:
233 ; RV32IDZFH-NEXT: fcvt.w.s a0, fa0, rmm
234 ; RV32IDZFH-NEXT: ret
236 ; RV64IZFH-LABEL: lround_f16:
238 ; RV64IZFH-NEXT: fcvt.l.s a0, fa0, rmm
241 ; RV64IDZFH-LABEL: lround_f16:
242 ; RV64IDZFH: # %bb.0:
243 ; RV64IDZFH-NEXT: fcvt.l.s a0, fa0, rmm
244 ; RV64IDZFH-NEXT: ret
245 %1 = call iXLen @llvm.lround.iXLen.f16(float %a)
249 declare i64 @llvm.llrint.i64.f16(float)
251 define i64 @llrint_f16(float %a) nounwind {
252 ; RV32IZFH-LABEL: llrint_f16:
254 ; RV32IZFH-NEXT: addi sp, sp, -16
255 ; RV32IZFH-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
256 ; RV32IZFH-NEXT: call llrintf@plt
257 ; RV32IZFH-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
258 ; RV32IZFH-NEXT: addi sp, sp, 16
261 ; RV32IDZFH-LABEL: llrint_f16:
262 ; RV32IDZFH: # %bb.0:
263 ; RV32IDZFH-NEXT: addi sp, sp, -16
264 ; RV32IDZFH-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
265 ; RV32IDZFH-NEXT: call llrintf@plt
266 ; RV32IDZFH-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
267 ; RV32IDZFH-NEXT: addi sp, sp, 16
268 ; RV32IDZFH-NEXT: ret
270 ; RV64IZFH-LABEL: llrint_f16:
272 ; RV64IZFH-NEXT: fcvt.l.s a0, fa0
275 ; RV64IDZFH-LABEL: llrint_f16:
276 ; RV64IDZFH: # %bb.0:
277 ; RV64IDZFH-NEXT: fcvt.l.s a0, fa0
278 ; RV64IDZFH-NEXT: ret
279 %1 = call i64 @llvm.llrint.i64.f16(float %a)
283 declare i64 @llvm.llround.i64.f16(float)
285 define i64 @llround_f16(float %a) nounwind {
286 ; RV32IZFH-LABEL: llround_f16:
288 ; RV32IZFH-NEXT: addi sp, sp, -16
289 ; RV32IZFH-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
290 ; RV32IZFH-NEXT: call llroundf@plt
291 ; RV32IZFH-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
292 ; RV32IZFH-NEXT: addi sp, sp, 16
295 ; RV32IDZFH-LABEL: llround_f16:
296 ; RV32IDZFH: # %bb.0:
297 ; RV32IDZFH-NEXT: addi sp, sp, -16
298 ; RV32IDZFH-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
299 ; RV32IDZFH-NEXT: call llroundf@plt
300 ; RV32IDZFH-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
301 ; RV32IDZFH-NEXT: addi sp, sp, 16
302 ; RV32IDZFH-NEXT: ret
304 ; RV64IZFH-LABEL: llround_f16:
306 ; RV64IZFH-NEXT: fcvt.l.s a0, fa0, rmm
309 ; RV64IDZFH-LABEL: llround_f16:
310 ; RV64IDZFH: # %bb.0:
311 ; RV64IDZFH-NEXT: fcvt.l.s a0, fa0, rmm
312 ; RV64IDZFH-NEXT: ret
313 %1 = call i64 @llvm.llround.i64.f16(float %a)