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: | FileCheck %s -check-prefix=RV64ID
5 ; This file exhaustively checks double<->i32 conversions. In general,
6 ; fcvt.l[u].d can be selected instead of fcvt.w[u].d 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(double %a) nounwind {
11 ; RV64ID-LABEL: aext_fptosi:
13 ; RV64ID-NEXT: fmv.d.x ft0, a0
14 ; RV64ID-NEXT: fcvt.l.d a0, ft0, rtz
16 %1 = fptosi double %a to i32
20 define signext i32 @sext_fptosi(double %a) nounwind {
21 ; RV64ID-LABEL: sext_fptosi:
23 ; RV64ID-NEXT: fmv.d.x ft0, a0
24 ; RV64ID-NEXT: fcvt.l.d a0, ft0, rtz
26 %1 = fptosi double %a to i32
30 define zeroext i32 @zext_fptosi(double %a) nounwind {
31 ; RV64ID-LABEL: zext_fptosi:
33 ; RV64ID-NEXT: fmv.d.x ft0, a0
34 ; RV64ID-NEXT: fcvt.l.d a0, ft0, rtz
35 ; RV64ID-NEXT: slli a0, a0, 32
36 ; RV64ID-NEXT: srli a0, a0, 32
38 %1 = fptosi double %a to i32
42 define i32 @aext_fptoui(double %a) nounwind {
43 ; RV64ID-LABEL: aext_fptoui:
45 ; RV64ID-NEXT: fmv.d.x ft0, a0
46 ; RV64ID-NEXT: fcvt.lu.d a0, ft0, rtz
48 %1 = fptoui double %a to i32
52 define signext i32 @sext_fptoui(double %a) nounwind {
53 ; RV64ID-LABEL: sext_fptoui:
55 ; RV64ID-NEXT: fmv.d.x ft0, a0
56 ; RV64ID-NEXT: fcvt.wu.d a0, ft0, rtz
58 %1 = fptoui double %a to i32
62 define zeroext i32 @zext_fptoui(double %a) nounwind {
63 ; RV64ID-LABEL: zext_fptoui:
65 ; RV64ID-NEXT: fmv.d.x ft0, a0
66 ; RV64ID-NEXT: fcvt.lu.d a0, ft0, rtz
68 %1 = fptoui double %a to i32
72 define double @uitofp_aext_i32_to_f64(i32 %a) nounwind {
73 ; RV64ID-LABEL: uitofp_aext_i32_to_f64:
75 ; RV64ID-NEXT: fcvt.d.wu ft0, a0
76 ; RV64ID-NEXT: fmv.x.d a0, ft0
78 %1 = uitofp i32 %a to double
82 define double @uitofp_sext_i32_to_f64(i32 signext %a) nounwind {
83 ; RV64ID-LABEL: uitofp_sext_i32_to_f64:
85 ; RV64ID-NEXT: fcvt.d.wu ft0, a0
86 ; RV64ID-NEXT: fmv.x.d a0, ft0
88 %1 = uitofp i32 %a to double
92 define double @uitofp_zext_i32_to_f64(i32 zeroext %a) nounwind {
93 ; RV64ID-LABEL: uitofp_zext_i32_to_f64:
95 ; RV64ID-NEXT: fcvt.d.wu ft0, a0
96 ; RV64ID-NEXT: fmv.x.d a0, ft0
98 %1 = uitofp i32 %a to double
102 define double @sitofp_aext_i32_to_f64(i32 %a) nounwind {
103 ; RV64ID-LABEL: sitofp_aext_i32_to_f64:
105 ; RV64ID-NEXT: fcvt.d.w ft0, a0
106 ; RV64ID-NEXT: fmv.x.d a0, ft0
108 %1 = sitofp i32 %a to double
112 define double @sitofp_sext_i32_to_f64(i32 signext %a) nounwind {
113 ; RV64ID-LABEL: sitofp_sext_i32_to_f64:
115 ; RV64ID-NEXT: fcvt.d.l ft0, a0
116 ; RV64ID-NEXT: fmv.x.d a0, ft0
118 %1 = sitofp i32 %a to double
122 define double @sitofp_zext_i32_to_f64(i32 zeroext %a) nounwind {
123 ; RV64ID-LABEL: sitofp_zext_i32_to_f64:
125 ; RV64ID-NEXT: fcvt.d.w ft0, a0
126 ; RV64ID-NEXT: fmv.x.d a0, ft0
128 %1 = sitofp i32 %a to double