1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+zfh -verify-machineinstrs \
3 ; RUN: -target-abi lp64f -disable-strictnode-mutation < %s | \
4 ; RUN: FileCheck %s -check-prefix=RV64IZFH
5 ; RUN: llc -mtriple=riscv64 -mattr=+zhinx -verify-machineinstrs \
6 ; RUN: -target-abi lp64 -disable-strictnode-mutation < %s | \
7 ; RUN: FileCheck %s -check-prefix=RV64IZHINX
9 ; This file exhaustively checks half<->i32 conversions. In general,
10 ; fcvt.l[u].h can be selected instead of fcvt.w[u].h because poison is
11 ; generated for an fpto[s|u]i conversion if the result doesn't fit in the
14 define i32 @aext_fptosi(half %a) nounwind strictfp {
15 ; RV64IZFH-LABEL: aext_fptosi:
17 ; RV64IZFH-NEXT: fcvt.w.h a0, fa0, rtz
20 ; RV64IZHINX-LABEL: aext_fptosi:
21 ; RV64IZHINX: # %bb.0:
22 ; RV64IZHINX-NEXT: fcvt.w.h a0, a0, rtz
23 ; RV64IZHINX-NEXT: ret
24 %1 = call i32 @llvm.experimental.constrained.fptosi.i32.f16(half %a, metadata !"fpexcept.strict")
27 declare i32 @llvm.experimental.constrained.fptosi.i32.f16(half, metadata)
29 define signext i32 @sext_fptosi(half %a) nounwind strictfp {
30 ; RV64IZFH-LABEL: sext_fptosi:
32 ; RV64IZFH-NEXT: fcvt.w.h a0, fa0, rtz
35 ; RV64IZHINX-LABEL: sext_fptosi:
36 ; RV64IZHINX: # %bb.0:
37 ; RV64IZHINX-NEXT: fcvt.w.h a0, a0, rtz
38 ; RV64IZHINX-NEXT: ret
39 %1 = call i32 @llvm.experimental.constrained.fptosi.i32.f16(half %a, metadata !"fpexcept.strict")
43 define zeroext i32 @zext_fptosi(half %a) nounwind strictfp {
44 ; RV64IZFH-LABEL: zext_fptosi:
46 ; RV64IZFH-NEXT: fcvt.w.h a0, fa0, rtz
47 ; RV64IZFH-NEXT: slli a0, a0, 32
48 ; RV64IZFH-NEXT: srli a0, a0, 32
51 ; RV64IZHINX-LABEL: zext_fptosi:
52 ; RV64IZHINX: # %bb.0:
53 ; RV64IZHINX-NEXT: fcvt.w.h a0, a0, rtz
54 ; RV64IZHINX-NEXT: slli a0, a0, 32
55 ; RV64IZHINX-NEXT: srli a0, a0, 32
56 ; RV64IZHINX-NEXT: ret
57 %1 = call i32 @llvm.experimental.constrained.fptosi.i32.f16(half %a, metadata !"fpexcept.strict")
61 define i32 @aext_fptoui(half %a) nounwind strictfp {
62 ; RV64IZFH-LABEL: aext_fptoui:
64 ; RV64IZFH-NEXT: fcvt.wu.h a0, fa0, rtz
67 ; RV64IZHINX-LABEL: aext_fptoui:
68 ; RV64IZHINX: # %bb.0:
69 ; RV64IZHINX-NEXT: fcvt.wu.h a0, a0, rtz
70 ; RV64IZHINX-NEXT: ret
71 %1 = call i32 @llvm.experimental.constrained.fptoui.i32.f16(half %a, metadata !"fpexcept.strict")
74 declare i32 @llvm.experimental.constrained.fptoui.i32.f16(half, metadata)
76 define signext i32 @sext_fptoui(half %a) nounwind strictfp {
77 ; RV64IZFH-LABEL: sext_fptoui:
79 ; RV64IZFH-NEXT: fcvt.wu.h a0, fa0, rtz
82 ; RV64IZHINX-LABEL: sext_fptoui:
83 ; RV64IZHINX: # %bb.0:
84 ; RV64IZHINX-NEXT: fcvt.wu.h a0, a0, rtz
85 ; RV64IZHINX-NEXT: ret
86 %1 = call i32 @llvm.experimental.constrained.fptoui.i32.f16(half %a, metadata !"fpexcept.strict")
90 define zeroext i32 @zext_fptoui(half %a) nounwind strictfp {
91 ; RV64IZFH-LABEL: zext_fptoui:
93 ; RV64IZFH-NEXT: fcvt.lu.h a0, fa0, rtz
96 ; RV64IZHINX-LABEL: zext_fptoui:
97 ; RV64IZHINX: # %bb.0:
98 ; RV64IZHINX-NEXT: fcvt.lu.h a0, a0, rtz
99 ; RV64IZHINX-NEXT: ret
100 %1 = call i32 @llvm.experimental.constrained.fptoui.i32.f16(half %a, metadata !"fpexcept.strict")
104 define half @uitofp_aext_i32_to_f16(i32 %a) nounwind strictfp {
105 ; RV64IZFH-LABEL: uitofp_aext_i32_to_f16:
107 ; RV64IZFH-NEXT: fcvt.h.wu fa0, a0
110 ; RV64IZHINX-LABEL: uitofp_aext_i32_to_f16:
111 ; RV64IZHINX: # %bb.0:
112 ; RV64IZHINX-NEXT: fcvt.h.wu a0, a0
113 ; RV64IZHINX-NEXT: ret
114 %1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
117 declare half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata, metadata)
119 define half @uitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
120 ; RV64IZFH-LABEL: uitofp_sext_i32_to_f16:
122 ; RV64IZFH-NEXT: fcvt.h.wu fa0, a0
125 ; RV64IZHINX-LABEL: uitofp_sext_i32_to_f16:
126 ; RV64IZHINX: # %bb.0:
127 ; RV64IZHINX-NEXT: fcvt.h.wu a0, a0
128 ; RV64IZHINX-NEXT: ret
129 %1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
133 define half @uitofp_zext_i32_to_f16(i32 zeroext %a) nounwind strictfp {
134 ; RV64IZFH-LABEL: uitofp_zext_i32_to_f16:
136 ; RV64IZFH-NEXT: fcvt.h.wu fa0, a0
139 ; RV64IZHINX-LABEL: uitofp_zext_i32_to_f16:
140 ; RV64IZHINX: # %bb.0:
141 ; RV64IZHINX-NEXT: fcvt.h.wu a0, a0
142 ; RV64IZHINX-NEXT: ret
143 %1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
147 define half @sitofp_aext_i32_to_f16(i32 %a) nounwind strictfp {
148 ; RV64IZFH-LABEL: sitofp_aext_i32_to_f16:
150 ; RV64IZFH-NEXT: fcvt.h.w fa0, a0
153 ; RV64IZHINX-LABEL: sitofp_aext_i32_to_f16:
154 ; RV64IZHINX: # %bb.0:
155 ; RV64IZHINX-NEXT: fcvt.h.w a0, a0
156 ; RV64IZHINX-NEXT: ret
157 %1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
160 declare half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata, metadata)
162 define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
163 ; RV64IZFH-LABEL: sitofp_sext_i32_to_f16:
165 ; RV64IZFH-NEXT: fcvt.h.w fa0, a0
168 ; RV64IZHINX-LABEL: sitofp_sext_i32_to_f16:
169 ; RV64IZHINX: # %bb.0:
170 ; RV64IZHINX-NEXT: fcvt.h.w a0, a0
171 ; RV64IZHINX-NEXT: ret
172 %1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
176 define half @sitofp_zext_i32_to_f16(i32 zeroext %a) nounwind strictfp {
177 ; RV64IZFH-LABEL: sitofp_zext_i32_to_f16:
179 ; RV64IZFH-NEXT: fcvt.h.w fa0, a0
182 ; RV64IZHINX-LABEL: sitofp_zext_i32_to_f16:
183 ; RV64IZHINX: # %bb.0:
184 ; RV64IZHINX-NEXT: fcvt.h.w a0, a0
185 ; RV64IZHINX-NEXT: ret
186 %1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")