1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+d -verify-machineinstrs < %s \
3 ; RUN: -target-abi=lp64d | FileCheck %s -check-prefix=RV64ID
4 ; RUN: llc -mtriple=riscv64 -mattr=+zdinx -verify-machineinstrs < %s \
5 ; RUN: -target-abi=lp64 | FileCheck %s -check-prefix=RV64IDINX
7 ; This file exhaustively checks double<->i32 conversions. In general,
8 ; fcvt.l[u].d can be selected instead of fcvt.w[u].d because poison is
9 ; generated for an fpto[s|u]i conversion if the result doesn't fit in the
12 define i32 @aext_fptosi(double %a) nounwind {
13 ; RV64ID-LABEL: aext_fptosi:
15 ; RV64ID-NEXT: fcvt.w.d a0, fa0, rtz
18 ; RV64IDINX-LABEL: aext_fptosi:
20 ; RV64IDINX-NEXT: fcvt.w.d a0, a0, rtz
22 %1 = fptosi double %a to i32
26 define signext i32 @sext_fptosi(double %a) nounwind {
27 ; RV64ID-LABEL: sext_fptosi:
29 ; RV64ID-NEXT: fcvt.w.d a0, fa0, rtz
32 ; RV64IDINX-LABEL: sext_fptosi:
34 ; RV64IDINX-NEXT: fcvt.w.d a0, a0, rtz
36 %1 = fptosi double %a to i32
40 define zeroext i32 @zext_fptosi(double %a) nounwind {
41 ; RV64ID-LABEL: zext_fptosi:
43 ; RV64ID-NEXT: fcvt.w.d a0, fa0, rtz
44 ; RV64ID-NEXT: slli a0, a0, 32
45 ; RV64ID-NEXT: srli a0, a0, 32
48 ; RV64IDINX-LABEL: zext_fptosi:
50 ; RV64IDINX-NEXT: fcvt.w.d a0, a0, rtz
51 ; RV64IDINX-NEXT: slli a0, a0, 32
52 ; RV64IDINX-NEXT: srli a0, a0, 32
54 %1 = fptosi double %a to i32
58 define i32 @aext_fptoui(double %a) nounwind {
59 ; RV64ID-LABEL: aext_fptoui:
61 ; RV64ID-NEXT: fcvt.wu.d a0, fa0, rtz
64 ; RV64IDINX-LABEL: aext_fptoui:
66 ; RV64IDINX-NEXT: fcvt.wu.d a0, a0, rtz
68 %1 = fptoui double %a to i32
72 define signext i32 @sext_fptoui(double %a) nounwind {
73 ; RV64ID-LABEL: sext_fptoui:
75 ; RV64ID-NEXT: fcvt.wu.d a0, fa0, rtz
78 ; RV64IDINX-LABEL: sext_fptoui:
80 ; RV64IDINX-NEXT: fcvt.wu.d a0, a0, rtz
82 %1 = fptoui double %a to i32
86 define zeroext i32 @zext_fptoui(double %a) nounwind {
87 ; RV64ID-LABEL: zext_fptoui:
89 ; RV64ID-NEXT: fcvt.lu.d a0, fa0, rtz
92 ; RV64IDINX-LABEL: zext_fptoui:
94 ; RV64IDINX-NEXT: fcvt.lu.d a0, a0, rtz
96 %1 = fptoui double %a to i32
100 define double @uitofp_aext_i32_to_f64(i32 %a) nounwind {
101 ; RV64ID-LABEL: uitofp_aext_i32_to_f64:
103 ; RV64ID-NEXT: fcvt.d.wu fa0, a0
106 ; RV64IDINX-LABEL: uitofp_aext_i32_to_f64:
107 ; RV64IDINX: # %bb.0:
108 ; RV64IDINX-NEXT: fcvt.d.wu a0, a0
109 ; RV64IDINX-NEXT: ret
110 %1 = uitofp i32 %a to double
114 define double @uitofp_sext_i32_to_f64(i32 signext %a) nounwind {
115 ; RV64ID-LABEL: uitofp_sext_i32_to_f64:
117 ; RV64ID-NEXT: fcvt.d.wu fa0, a0
120 ; RV64IDINX-LABEL: uitofp_sext_i32_to_f64:
121 ; RV64IDINX: # %bb.0:
122 ; RV64IDINX-NEXT: fcvt.d.wu a0, a0
123 ; RV64IDINX-NEXT: ret
124 %1 = uitofp i32 %a to double
128 define double @uitofp_zext_i32_to_f64(i32 zeroext %a) nounwind {
129 ; RV64ID-LABEL: uitofp_zext_i32_to_f64:
131 ; RV64ID-NEXT: fcvt.d.wu fa0, a0
134 ; RV64IDINX-LABEL: uitofp_zext_i32_to_f64:
135 ; RV64IDINX: # %bb.0:
136 ; RV64IDINX-NEXT: fcvt.d.wu a0, a0
137 ; RV64IDINX-NEXT: ret
138 %1 = uitofp i32 %a to double
142 define double @sitofp_aext_i32_to_f64(i32 %a) nounwind {
143 ; RV64ID-LABEL: sitofp_aext_i32_to_f64:
145 ; RV64ID-NEXT: fcvt.d.w fa0, a0
148 ; RV64IDINX-LABEL: sitofp_aext_i32_to_f64:
149 ; RV64IDINX: # %bb.0:
150 ; RV64IDINX-NEXT: fcvt.d.w a0, a0
151 ; RV64IDINX-NEXT: ret
152 %1 = sitofp i32 %a to double
156 define double @sitofp_sext_i32_to_f64(i32 signext %a) nounwind {
157 ; RV64ID-LABEL: sitofp_sext_i32_to_f64:
159 ; RV64ID-NEXT: fcvt.d.w fa0, a0
162 ; RV64IDINX-LABEL: sitofp_sext_i32_to_f64:
163 ; RV64IDINX: # %bb.0:
164 ; RV64IDINX-NEXT: fcvt.d.w a0, a0
165 ; RV64IDINX-NEXT: ret
166 %1 = sitofp i32 %a to double
170 define double @sitofp_zext_i32_to_f64(i32 zeroext %a) nounwind {
171 ; RV64ID-LABEL: sitofp_zext_i32_to_f64:
173 ; RV64ID-NEXT: fcvt.d.w fa0, a0
176 ; RV64IDINX-LABEL: sitofp_zext_i32_to_f64:
177 ; RV64IDINX: # %bb.0:
178 ; RV64IDINX-NEXT: fcvt.d.w a0, a0
179 ; RV64IDINX-NEXT: ret
180 %1 = sitofp i32 %a to double