1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi=lp64f -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64IF
5 ; This file exhaustively checks float<->i32 conversions. In general,
6 ; fcvt.l[u].s can be selected instead of fcvt.w[u].s because poison is
7 ; generated for an fpto[s|u]i conversion if the result doesn't fit in the
10 define i32 @aext_fptosi(float %a) nounwind {
11 ; RV64IF-LABEL: aext_fptosi:
13 ; RV64IF-NEXT: fcvt.w.s a0, fa0, rtz
15 %1 = fptosi float %a to i32
19 define signext i32 @sext_fptosi(float %a) nounwind {
20 ; RV64IF-LABEL: sext_fptosi:
22 ; RV64IF-NEXT: fcvt.w.s a0, fa0, rtz
24 %1 = fptosi float %a to i32
28 define zeroext i32 @zext_fptosi(float %a) nounwind {
29 ; RV64IF-LABEL: zext_fptosi:
31 ; RV64IF-NEXT: fcvt.w.s a0, fa0, rtz
32 ; RV64IF-NEXT: slli a0, a0, 32
33 ; RV64IF-NEXT: srli a0, a0, 32
35 %1 = fptosi float %a to i32
39 define i32 @aext_fptoui(float %a) nounwind {
40 ; RV64IF-LABEL: aext_fptoui:
42 ; RV64IF-NEXT: fcvt.wu.s a0, fa0, rtz
44 %1 = fptoui float %a to i32
48 define signext i32 @sext_fptoui(float %a) nounwind {
49 ; RV64IF-LABEL: sext_fptoui:
51 ; RV64IF-NEXT: fcvt.wu.s a0, fa0, rtz
53 %1 = fptoui float %a to i32
57 define zeroext i32 @zext_fptoui(float %a) nounwind {
58 ; RV64IF-LABEL: zext_fptoui:
60 ; RV64IF-NEXT: fcvt.lu.s a0, fa0, rtz
62 %1 = fptoui float %a to i32
66 define i32 @bcvt_f32_to_aext_i32(float %a, float %b) nounwind {
67 ; RV64IF-LABEL: bcvt_f32_to_aext_i32:
69 ; RV64IF-NEXT: fadd.s ft0, fa0, fa1
70 ; RV64IF-NEXT: fmv.x.w a0, ft0
72 %1 = fadd float %a, %b
73 %2 = bitcast float %1 to i32
77 define signext i32 @bcvt_f32_to_sext_i32(float %a, float %b) nounwind {
78 ; RV64IF-LABEL: bcvt_f32_to_sext_i32:
80 ; RV64IF-NEXT: fadd.s ft0, fa0, fa1
81 ; RV64IF-NEXT: fmv.x.w a0, ft0
83 %1 = fadd float %a, %b
84 %2 = bitcast float %1 to i32
88 define zeroext i32 @bcvt_f32_to_zext_i32(float %a, float %b) nounwind {
89 ; RV64IF-LABEL: bcvt_f32_to_zext_i32:
91 ; RV64IF-NEXT: fadd.s ft0, fa0, fa1
92 ; RV64IF-NEXT: fmv.x.w a0, ft0
93 ; RV64IF-NEXT: slli a0, a0, 32
94 ; RV64IF-NEXT: srli a0, a0, 32
96 %1 = fadd float %a, %b
97 %2 = bitcast float %1 to i32
101 define float @bcvt_i64_to_f32_via_i32(i64 %a, i64 %b) nounwind {
102 ; RV64IF-LABEL: bcvt_i64_to_f32_via_i32:
104 ; RV64IF-NEXT: fmv.w.x ft0, a0
105 ; RV64IF-NEXT: fmv.w.x ft1, a1
106 ; RV64IF-NEXT: fadd.s fa0, ft0, ft1
108 %1 = trunc i64 %a to i32
109 %2 = trunc i64 %b to i32
110 %3 = bitcast i32 %1 to float
111 %4 = bitcast i32 %2 to float
112 %5 = fadd float %3, %4
116 define float @uitofp_aext_i32_to_f32(i32 %a) nounwind {
117 ; RV64IF-LABEL: uitofp_aext_i32_to_f32:
119 ; RV64IF-NEXT: fcvt.s.wu fa0, a0
121 %1 = uitofp i32 %a to float
125 define float @uitofp_sext_i32_to_f32(i32 signext %a) nounwind {
126 ; RV64IF-LABEL: uitofp_sext_i32_to_f32:
128 ; RV64IF-NEXT: fcvt.s.wu fa0, a0
130 %1 = uitofp i32 %a to float
134 define float @uitofp_zext_i32_to_f32(i32 zeroext %a) nounwind {
135 ; RV64IF-LABEL: uitofp_zext_i32_to_f32:
137 ; RV64IF-NEXT: fcvt.s.wu fa0, a0
139 %1 = uitofp i32 %a to float
143 define float @sitofp_aext_i32_to_f32(i32 %a) nounwind {
144 ; RV64IF-LABEL: sitofp_aext_i32_to_f32:
146 ; RV64IF-NEXT: fcvt.s.w fa0, a0
148 %1 = sitofp i32 %a to float
152 define float @sitofp_sext_i32_to_f32(i32 signext %a) nounwind {
153 ; RV64IF-LABEL: sitofp_sext_i32_to_f32:
155 ; RV64IF-NEXT: fcvt.s.w fa0, a0
157 %1 = sitofp i32 %a to float
161 define float @sitofp_zext_i32_to_f32(i32 zeroext %a) nounwind {
162 ; RV64IF-LABEL: sitofp_zext_i32_to_f32:
164 ; RV64IF-NEXT: fcvt.s.w fa0, a0
166 %1 = sitofp i32 %a to float