[llvm] [RISCV] Custom promote f16/bf16 (s/u)int_to_fp. (PR #107026)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 10:20:30 PDT 2024
https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/107026
>From 1d6080aeecec63bab46df432d9874c7b92c8f035 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 2 Sep 2024 15:53:36 -0700
Subject: [PATCH 1/2] [RISCV] Custom promote f16/bf16 (s/u)int_to_fp.
This avoids having isel patterns that emit two instrutions. It also
allows us to remove sext.w and slli+srli pairs by using fcvt.s.w(u)
on RV64.
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 40 ++++++++--
.../lib/Target/RISCV/RISCVInstrInfoZfbfmin.td | 8 --
llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td | 16 ----
llvm/test/CodeGen/RISCV/bfloat-convert.ll | 25 +++----
.../test/CodeGen/RISCV/half-convert-strict.ll | 75 ++++++++-----------
llvm/test/CodeGen/RISCV/half-convert.ll | 75 ++++++++-----------
.../RISCV/rv64zfhmin-half-convert-strict.ll | 36 +++------
.../CodeGen/RISCV/rv64zfhmin-half-convert.ll | 36 +++------
8 files changed, 129 insertions(+), 182 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 250d1c60b9f59e..eb7af7e951a3bf 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -460,6 +460,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::FABS, MVT::bf16, Custom);
setOperationAction(ISD::FNEG, MVT::bf16, Custom);
setOperationAction(ISD::FCOPYSIGN, MVT::bf16, Expand);
+ setOperationAction({ISD::SINT_TO_FP, ISD::UINT_TO_FP}, XLenVT, Custom);
}
if (Subtarget.hasStdExtZfhminOrZhinxmin()) {
@@ -478,6 +479,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::FABS, MVT::f16, Custom);
setOperationAction(ISD::FNEG, MVT::f16, Custom);
setOperationAction(ISD::FCOPYSIGN, MVT::f16, Expand);
+ setOperationAction({ISD::SINT_TO_FP, ISD::UINT_TO_FP}, XLenVT, Custom);
}
setOperationAction(ISD::STRICT_FP_ROUND, MVT::f16, Legal);
@@ -590,9 +592,10 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
setOperationAction({ISD::FP_TO_UINT_SAT, ISD::FP_TO_SINT_SAT}, XLenVT,
Custom);
- setOperationAction({ISD::STRICT_FP_TO_UINT, ISD::STRICT_FP_TO_SINT,
- ISD::STRICT_UINT_TO_FP, ISD::STRICT_SINT_TO_FP},
+ setOperationAction({ISD::STRICT_FP_TO_UINT, ISD::STRICT_FP_TO_SINT},
XLenVT, Legal);
+ setOperationAction({ISD::STRICT_UINT_TO_FP, ISD::STRICT_SINT_TO_FP},
+ XLenVT, Custom);
setOperationAction(ISD::GET_ROUNDING, XLenVT, Custom);
setOperationAction(ISD::SET_ROUNDING, MVT::Other, Custom);
@@ -2953,6 +2956,31 @@ InstructionCost RISCVTargetLowering::getVSlideVICost(MVT VT) const {
return getLMULCost(VT);
}
+static SDValue lowerINT_TO_FP(SDValue Op, SelectionDAG &DAG,
+ const RISCVSubtarget &Subtarget) {
+ // f16 conversions are promoted to f32 when Zfh/Zhinx are not supported.
+ // bf16 conversions are always promoted to f32.
+ if ((Op.getValueType() == MVT::f16 && !Subtarget.hasStdExtZfhOrZhinx()) ||
+ Op.getValueType() == MVT::bf16) {
+ bool IsStrict = Op->isStrictFPOpcode();
+
+ SDLoc DL(Op);
+ if (IsStrict) {
+ SDValue Val = DAG.getNode(Op.getOpcode(), DL, {MVT::f32, MVT::Other},
+ {Op.getOperand(0), Op.getOperand(1)});
+ return DAG.getNode(
+ ISD::STRICT_FP_ROUND, DL, {Op.getValueType(), MVT::Other},
+ {Val.getValue(1), Val.getValue(0), DAG.getIntPtrConstant(0, DL, /*isTarget=*/true)});
+ }
+ return DAG.getNode(ISD::FP_ROUND, DL, Op.getValueType(),
+ DAG.getNode(Op.getOpcode(), DL, MVT::f32, Op.getOperand(0)),
+ DAG.getIntPtrConstant(0, DL, /*isTarget=*/true));
+ }
+
+ // Other operations are legal.
+ return Op;
+}
+
static SDValue lowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG,
const RISCVSubtarget &Subtarget) {
// RISC-V FP-to-int conversions saturate to the destination register size, but
@@ -6568,13 +6596,15 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
// the source. We custom-lower any conversions that do two hops into
// sequences.
MVT VT = Op.getSimpleValueType();
+ bool IsStrict = Op->isStrictFPOpcode();
+ SDValue Src = Op.getOperand(0 + IsStrict);
+ MVT SrcVT = Src.getSimpleValueType();
+ if (SrcVT.isScalarInteger())
+ return lowerINT_TO_FP(Op, DAG, Subtarget);
if (!VT.isVector())
return Op;
SDLoc DL(Op);
- bool IsStrict = Op->isStrictFPOpcode();
- SDValue Src = Op.getOperand(0 + IsStrict);
MVT EltVT = VT.getVectorElementType();
- MVT SrcVT = Src.getSimpleValueType();
MVT SrcEltVT = SrcVT.getVectorElementType();
unsigned EltSize = EltVT.getSizeInBits();
unsigned SrcEltSize = SrcEltVT.getSizeInBits();
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfbfmin.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfbfmin.td
index bf6272317fda4d..753c53f1b466e3 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfbfmin.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfbfmin.td
@@ -63,10 +63,6 @@ let Predicates = [HasStdExtZfbfmin] in {
// rounding mode has no effect for bf16->f32.
def : Pat<(i32 (any_fp_to_sint (bf16 FPR16:$rs1))), (FCVT_W_S (FCVT_S_BF16 $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i32 (any_fp_to_uint (bf16 FPR16:$rs1))), (FCVT_WU_S (FCVT_S_BF16 $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->bf16. Match GCC and default to using dynamic rounding mode.
-def : Pat<(bf16 (any_sint_to_fp (i32 GPR:$rs1))), (FCVT_BF16_S (FCVT_S_W $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(bf16 (any_uint_to_fp (i32 GPR:$rs1))), (FCVT_BF16_S (FCVT_S_WU $rs1, FRM_DYN), FRM_DYN)>;
}
let Predicates = [HasStdExtZfbfmin, IsRV64] in {
@@ -74,10 +70,6 @@ let Predicates = [HasStdExtZfbfmin, IsRV64] in {
// rounding mode has no effect for bf16->f32.
def : Pat<(i64 (any_fp_to_sint (bf16 FPR16:$rs1))), (FCVT_L_S (FCVT_S_BF16 $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i64 (any_fp_to_uint (bf16 FPR16:$rs1))), (FCVT_LU_S (FCVT_S_BF16 $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->bf16. Match GCC and default to using dynamic rounding mode.
-def : Pat<(bf16 (any_sint_to_fp (i64 GPR:$rs1))), (FCVT_BF16_S (FCVT_S_L $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(bf16 (any_uint_to_fp (i64 GPR:$rs1))), (FCVT_BF16_S (FCVT_S_LU $rs1, FRM_DYN), FRM_DYN)>;
}
let Predicates = [HasStdExtZfbfmin, HasStdExtD] in {
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
index d60cf33567d6d0..2f047a6dccdf46 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
@@ -604,38 +604,22 @@ let Predicates = [HasStdExtZfhmin, NoStdExtZfh] in {
// half->[u]int. Round-to-zero must be used.
def : Pat<(i32 (any_fp_to_sint (f16 FPR16:$rs1))), (FCVT_W_S (FCVT_S_H $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i32 (any_fp_to_uint (f16 FPR16:$rs1))), (FCVT_WU_S (FCVT_S_H $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->half. Match GCC and default to using dynamic rounding mode.
-def : Pat<(f16 (any_sint_to_fp (i32 GPR:$rs1))), (FCVT_H_S (FCVT_S_W $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(f16 (any_uint_to_fp (i32 GPR:$rs1))), (FCVT_H_S (FCVT_S_WU $rs1, FRM_DYN), FRM_DYN)>;
} // Predicates = [HasStdExtZfhmin, NoStdExtZfh]
let Predicates = [HasStdExtZhinxmin, NoStdExtZhinx] in {
// half->[u]int. Round-to-zero must be used.
def : Pat<(i32 (any_fp_to_sint FPR16INX:$rs1)), (FCVT_W_S_INX (FCVT_S_H_INX $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i32 (any_fp_to_uint FPR16INX:$rs1)), (FCVT_WU_S_INX (FCVT_S_H_INX $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->half. Match GCC and default to using dynamic rounding mode.
-def : Pat<(any_sint_to_fp (i32 GPR:$rs1)), (FCVT_H_S_INX (FCVT_S_W_INX $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(any_uint_to_fp (i32 GPR:$rs1)), (FCVT_H_S_INX (FCVT_S_WU_INX $rs1, FRM_DYN), FRM_DYN)>;
} // Predicates = [HasStdExtZhinxmin, NoStdExtZhinx]
let Predicates = [HasStdExtZfhmin, NoStdExtZfh, IsRV64] in {
// half->[u]int64. Round-to-zero must be used.
def : Pat<(i64 (any_fp_to_sint (f16 FPR16:$rs1))), (FCVT_L_S (FCVT_S_H $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i64 (any_fp_to_uint (f16 FPR16:$rs1))), (FCVT_LU_S (FCVT_S_H $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->fp. Match GCC and default to using dynamic rounding mode.
-def : Pat<(f16 (any_sint_to_fp (i64 GPR:$rs1))), (FCVT_H_S (FCVT_S_L $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(f16 (any_uint_to_fp (i64 GPR:$rs1))), (FCVT_H_S (FCVT_S_LU $rs1, FRM_DYN), FRM_DYN)>;
} // Predicates = [HasStdExtZfhmin, NoStdExtZfh, IsRV64]
let Predicates = [HasStdExtZhinxmin, NoStdExtZhinx, IsRV64] in {
// half->[u]int64. Round-to-zero must be used.
def : Pat<(i64 (any_fp_to_sint FPR16INX:$rs1)), (FCVT_L_S_INX (FCVT_S_H_INX $rs1, FRM_RNE), FRM_RTZ)>;
def : Pat<(i64 (any_fp_to_uint FPR16INX:$rs1)), (FCVT_LU_S_INX (FCVT_S_H_INX $rs1, FRM_RNE), FRM_RTZ)>;
-
-// [u]int->fp. Match GCC and default to using dynamic rounding mode.
-def : Pat<(any_sint_to_fp (i64 GPR:$rs1)), (FCVT_H_S_INX (FCVT_S_L_INX $rs1, FRM_DYN), FRM_DYN)>;
-def : Pat<(any_uint_to_fp (i64 GPR:$rs1)), (FCVT_H_S_INX (FCVT_S_LU_INX $rs1, FRM_DYN), FRM_DYN)>;
} // Predicates = [HasStdExtZhinxmin, NoStdExtZhinx, IsRV64]
diff --git a/llvm/test/CodeGen/RISCV/bfloat-convert.ll b/llvm/test/CodeGen/RISCV/bfloat-convert.ll
index 6d90def954bdb0..37ea80e6ae7726 100644
--- a/llvm/test/CodeGen/RISCV/bfloat-convert.ll
+++ b/llvm/test/CodeGen/RISCV/bfloat-convert.ll
@@ -749,7 +749,7 @@ define bfloat @fcvt_bf16_si(i16 %a) nounwind {
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: slli a0, a0, 48
; CHECK64ZFBFMIN-NEXT: srai a0, a0, 48
-; CHECK64ZFBFMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -795,7 +795,7 @@ define bfloat @fcvt_bf16_si_signext(i16 signext %a) nounwind {
;
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_si_signext:
; CHECK64ZFBFMIN: # %bb.0:
-; CHECK64ZFBFMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -845,7 +845,7 @@ define bfloat @fcvt_bf16_ui(i16 %a) nounwind {
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: slli a0, a0, 48
; CHECK64ZFBFMIN-NEXT: srli a0, a0, 48
-; CHECK64ZFBFMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -891,7 +891,7 @@ define bfloat @fcvt_bf16_ui_zeroext(i16 zeroext %a) nounwind {
;
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_ui_zeroext:
; CHECK64ZFBFMIN: # %bb.0:
-; CHECK64ZFBFMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -935,8 +935,7 @@ define bfloat @fcvt_bf16_w(i32 %a) nounwind {
;
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_w:
; CHECK64ZFBFMIN: # %bb.0:
-; CHECK64ZFBFMIN-NEXT: sext.w a0, a0
-; CHECK64ZFBFMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -983,7 +982,7 @@ define bfloat @fcvt_bf16_w_load(ptr %p) nounwind {
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_w_load:
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: lw a0, 0(a0)
-; CHECK64ZFBFMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -1029,9 +1028,7 @@ define bfloat @fcvt_bf16_wu(i32 %a) nounwind {
;
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_wu:
; CHECK64ZFBFMIN: # %bb.0:
-; CHECK64ZFBFMIN-NEXT: slli a0, a0, 32
-; CHECK64ZFBFMIN-NEXT: srli a0, a0, 32
-; CHECK64ZFBFMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -1078,7 +1075,7 @@ define bfloat @fcvt_bf16_wu_load(ptr %p) nounwind {
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_wu_load:
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: lwu a0, 0(a0)
-; CHECK64ZFBFMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa0, fa5
; CHECK64ZFBFMIN-NEXT: ret
;
@@ -1376,7 +1373,7 @@ define signext i32 @fcvt_bf16_w_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_w_demanded_bits:
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: addiw a0, a0, 1
-; CHECK64ZFBFMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64ZFBFMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa5, fa5
; CHECK64ZFBFMIN-NEXT: fsh fa5, 0(a1)
; CHECK64ZFBFMIN-NEXT: ret
@@ -1436,9 +1433,7 @@ define signext i32 @fcvt_bf16_wu_demanded_bits(i32 signext %0, ptr %1) nounwind
; CHECK64ZFBFMIN-LABEL: fcvt_bf16_wu_demanded_bits:
; CHECK64ZFBFMIN: # %bb.0:
; CHECK64ZFBFMIN-NEXT: addiw a0, a0, 1
-; CHECK64ZFBFMIN-NEXT: slli a2, a0, 32
-; CHECK64ZFBFMIN-NEXT: srli a2, a2, 32
-; CHECK64ZFBFMIN-NEXT: fcvt.s.lu fa5, a2
+; CHECK64ZFBFMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64ZFBFMIN-NEXT: fcvt.bf16.s fa5, fa5
; CHECK64ZFBFMIN-NEXT: fsh fa5, 0(a1)
; CHECK64ZFBFMIN-NEXT: ret
diff --git a/llvm/test/CodeGen/RISCV/half-convert-strict.ll b/llvm/test/CodeGen/RISCV/half-convert-strict.ll
index 8f88a4c570ea05..164d9a59e645cf 100644
--- a/llvm/test/CodeGen/RISCV/half-convert-strict.ll
+++ b/llvm/test/CodeGen/RISCV/half-convert-strict.ll
@@ -736,7 +736,7 @@ define half @fcvt_h_si(i16 %a) nounwind strictfp {
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: slli a0, a0, 48
; CHECK64-IZFHMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -752,7 +752,7 @@ define half @fcvt_h_si(i16 %a) nounwind strictfp {
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZHINXMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -768,7 +768,7 @@ define half @fcvt_h_si(i16 %a) nounwind strictfp {
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZDINXZHINXMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i16(i16 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -815,7 +815,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind strictfp {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -827,7 +827,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind strictfp {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -839,7 +839,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind strictfp {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i16(i16 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -915,7 +915,7 @@ define half @fcvt_h_ui(i16 %a) nounwind strictfp {
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: slli a0, a0, 48
; CHECK64-IZFHMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -931,7 +931,7 @@ define half @fcvt_h_ui(i16 %a) nounwind strictfp {
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZHINXMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -947,7 +947,7 @@ define half @fcvt_h_ui(i16 %a) nounwind strictfp {
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZDINXZHINXMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i16(i16 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -994,7 +994,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind strictfp {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -1006,7 +1006,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind strictfp {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -1018,7 +1018,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind strictfp {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i16(i16 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -1064,8 +1064,7 @@ define half @fcvt_h_w(i32 %a) nounwind strictfp {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_w:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: sext.w a0, a0
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -1077,8 +1076,7 @@ define half @fcvt_h_w(i32 %a) nounwind strictfp {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: sext.w a0, a0
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -1090,8 +1088,7 @@ define half @fcvt_h_w(i32 %a) nounwind strictfp {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: sext.w a0, a0
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -1146,7 +1143,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind strictfp {
; CHECK64-IZFHMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -1160,7 +1157,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind strictfp {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -1174,7 +1171,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind strictfp {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%a = load i32, ptr %p
@@ -1221,9 +1218,7 @@ define half @fcvt_h_wu(i32 %a) nounwind strictfp {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZFHMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -1235,9 +1230,7 @@ define half @fcvt_h_wu(i32 %a) nounwind strictfp {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZHINXMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -1249,9 +1242,7 @@ define half @fcvt_h_wu(i32 %a) nounwind strictfp {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -1318,7 +1309,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind strictfp {
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -1332,7 +1323,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind strictfp {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -1346,7 +1337,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind strictfp {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%a = load i32, ptr %p
@@ -2007,7 +1998,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZFHMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa5, fa5
; CHECK64-IZFHMIN-NEXT: fsh fa5, 0(a1)
; CHECK64-IZFHMIN-NEXT: ret
@@ -2023,7 +2014,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a2, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a2, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZHINXMIN-NEXT: ret
@@ -2039,7 +2030,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a2, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a2, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZDINXZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZDINXZHINXMIN-NEXT: ret
@@ -2118,9 +2109,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZFHMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZFHMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a2
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa5, fa5
; CHECK64-IZFHMIN-NEXT: fsh fa5, 0(a1)
; CHECK64-IZFHMIN-NEXT: ret
@@ -2136,9 +2125,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZHINXMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZHINXMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a2, a2
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a2, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZHINXMIN-NEXT: ret
@@ -2154,9 +2141,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) strictfp {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZDINXZHINXMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a2, a2
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a2, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZDINXZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZDINXZHINXMIN-NEXT: ret
diff --git a/llvm/test/CodeGen/RISCV/half-convert.ll b/llvm/test/CodeGen/RISCV/half-convert.ll
index 48bfe1c37c625c..d46376339e0e5e 100644
--- a/llvm/test/CodeGen/RISCV/half-convert.ll
+++ b/llvm/test/CodeGen/RISCV/half-convert.ll
@@ -3467,7 +3467,7 @@ define half @fcvt_h_si(i16 %a) nounwind {
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: slli a0, a0, 48
; CHECK64-IZFHMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -3483,7 +3483,7 @@ define half @fcvt_h_si(i16 %a) nounwind {
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZHINXMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -3499,7 +3499,7 @@ define half @fcvt_h_si(i16 %a) nounwind {
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZDINXZHINXMIN-NEXT: srai a0, a0, 48
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = sitofp i16 %a to half
@@ -3614,7 +3614,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -3626,7 +3626,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -3638,7 +3638,7 @@ define half @fcvt_h_si_signext(i16 signext %a) nounwind {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_si_signext:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = sitofp i16 %a to half
@@ -3800,7 +3800,7 @@ define half @fcvt_h_ui(i16 %a) nounwind {
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: slli a0, a0, 48
; CHECK64-IZFHMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -3816,7 +3816,7 @@ define half @fcvt_h_ui(i16 %a) nounwind {
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZHINXMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -3832,7 +3832,7 @@ define half @fcvt_h_ui(i16 %a) nounwind {
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 48
; CHECK64-IZDINXZHINXMIN-NEXT: srli a0, a0, 48
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = uitofp i16 %a to half
@@ -3947,7 +3947,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -3959,7 +3959,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -3971,7 +3971,7 @@ define half @fcvt_h_ui_zeroext(i16 zeroext %a) nounwind {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_ui_zeroext:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = uitofp i16 %a to half
@@ -4087,8 +4087,7 @@ define half @fcvt_h_w(i32 %a) nounwind {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_w:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: sext.w a0, a0
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -4100,8 +4099,7 @@ define half @fcvt_h_w(i32 %a) nounwind {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: sext.w a0, a0
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -4113,8 +4111,7 @@ define half @fcvt_h_w(i32 %a) nounwind {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: sext.w a0, a0
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = sitofp i32 %a to half
@@ -4242,7 +4239,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind {
; CHECK64-IZFHMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -4256,7 +4253,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -4270,7 +4267,7 @@ define half @fcvt_h_w_load(ptr %p) nounwind {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w_load:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: lw a0, 0(a0)
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%a = load i32, ptr %p
@@ -4387,9 +4384,7 @@ define half @fcvt_h_wu(i32 %a) nounwind {
;
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu:
; CHECK64-IZFHMIN: # %bb.0:
-; CHECK64-IZFHMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZFHMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -4401,9 +4396,7 @@ define half @fcvt_h_wu(i32 %a) nounwind {
;
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu:
; CHECK64-IZHINXMIN: # %bb.0:
-; CHECK64-IZHINXMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZHINXMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -4415,9 +4408,7 @@ define half @fcvt_h_wu(i32 %a) nounwind {
;
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
-; CHECK64-IZDINXZHINXMIN-NEXT: slli a0, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: srli a0, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%1 = uitofp i32 %a to half
@@ -4563,7 +4554,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind {
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; CHECK64-IZFHMIN-NEXT: ret
;
@@ -4577,7 +4568,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZHINXMIN-NEXT: ret
;
@@ -4591,7 +4582,7 @@ define half @fcvt_h_wu_load(ptr %p) nounwind {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu_load:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: lwu a0, 0(a0)
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a0, a0
; CHECK64-IZDINXZHINXMIN-NEXT: ret
%a = load i32, ptr %p
@@ -5904,7 +5895,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZFHMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; CHECK64-IZFHMIN-NEXT: fcvt.s.w fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa5, fa5
; CHECK64-IZFHMIN-NEXT: fsh fa5, 0(a1)
; CHECK64-IZFHMIN-NEXT: ret
@@ -5920,7 +5911,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.l a2, a0
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.w a2, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZHINXMIN-NEXT: ret
@@ -5936,7 +5927,7 @@ define signext i32 @fcvt_h_w_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_w_demanded_bits:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.l a2, a0
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.w a2, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZDINXZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZDINXZHINXMIN-NEXT: ret
@@ -6129,9 +6120,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZFHMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZFHMIN: # %bb.0:
; CHECK64-IZFHMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZFHMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZFHMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZFHMIN-NEXT: fcvt.s.lu fa5, a2
+; CHECK64-IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; CHECK64-IZFHMIN-NEXT: fcvt.h.s fa5, fa5
; CHECK64-IZFHMIN-NEXT: fsh fa5, 0(a1)
; CHECK64-IZFHMIN-NEXT: ret
@@ -6147,9 +6136,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZHINXMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZHINXMIN: # %bb.0:
; CHECK64-IZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZHINXMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZHINXMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZHINXMIN-NEXT: fcvt.s.lu a2, a2
+; CHECK64-IZHINXMIN-NEXT: fcvt.s.wu a2, a0
; CHECK64-IZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZHINXMIN-NEXT: ret
@@ -6165,9 +6152,7 @@ define signext i32 @fcvt_h_wu_demanded_bits(i32 signext %0, ptr %1) nounwind {
; CHECK64-IZDINXZHINXMIN-LABEL: fcvt_h_wu_demanded_bits:
; CHECK64-IZDINXZHINXMIN: # %bb.0:
; CHECK64-IZDINXZHINXMIN-NEXT: addiw a0, a0, 1
-; CHECK64-IZDINXZHINXMIN-NEXT: slli a2, a0, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: srli a2, a2, 32
-; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.lu a2, a2
+; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.s.wu a2, a0
; CHECK64-IZDINXZHINXMIN-NEXT: fcvt.h.s a2, a2
; CHECK64-IZDINXZHINXMIN-NEXT: sh a2, 0(a1)
; CHECK64-IZDINXZHINXMIN-NEXT: ret
diff --git a/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert-strict.ll b/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert-strict.ll
index 7c0b84f9c18632..41d66382679f18 100644
--- a/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert-strict.ll
+++ b/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert-strict.ll
@@ -113,17 +113,13 @@ define zeroext i32 @zext_fptoui(half %a) nounwind strictfp {
define half @uitofp_aext_i32_to_f16(i32 %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: uitofp_aext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: slli a0, a0, 32
-; RV64IZFHMIN-NEXT: srli a0, a0, 32
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_aext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: slli a0, a0, 32
-; RV64IZHINXMIN-NEXT: srli a0, a0, 32
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -134,17 +130,13 @@ declare half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata, met
define half @uitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: uitofp_sext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: slli a0, a0, 32
-; RV64IZFHMIN-NEXT: srli a0, a0, 32
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_sext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: slli a0, a0, 32
-; RV64IZHINXMIN-NEXT: srli a0, a0, 32
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -154,13 +146,13 @@ define half @uitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
define half @uitofp_zext_i32_to_f16(i32 zeroext %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: uitofp_zext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_zext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.uitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -170,15 +162,13 @@ define half @uitofp_zext_i32_to_f16(i32 zeroext %a) nounwind strictfp {
define half @sitofp_aext_i32_to_f16(i32 %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: sitofp_aext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: sext.w a0, a0
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_aext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: sext.w a0, a0
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -189,13 +179,13 @@ declare half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata, met
define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: sitofp_sext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_sext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
@@ -205,15 +195,13 @@ define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind strictfp {
define half @sitofp_zext_i32_to_f16(i32 zeroext %a) nounwind strictfp {
; RV64IZFHMIN-LABEL: sitofp_zext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: sext.w a0, a0
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_zext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: sext.w a0, a0
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = call half @llvm.experimental.constrained.sitofp.f16.i32(i32 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
diff --git a/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert.ll b/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert.ll
index aac1a65e6c4fec..1ec710c110ba9a 100644
--- a/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert.ll
+++ b/llvm/test/CodeGen/RISCV/rv64zfhmin-half-convert.ll
@@ -207,17 +207,13 @@ define half @bcvt_i64_to_f16_via_i16(i64 %a, i64 %b) nounwind {
define half @uitofp_aext_i32_to_f16(i32 %a) nounwind {
; RV64IZFHMIN-LABEL: uitofp_aext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: slli a0, a0, 32
-; RV64IZFHMIN-NEXT: srli a0, a0, 32
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_aext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: slli a0, a0, 32
-; RV64IZHINXMIN-NEXT: srli a0, a0, 32
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = uitofp i32 %a to half
@@ -227,17 +223,13 @@ define half @uitofp_aext_i32_to_f16(i32 %a) nounwind {
define half @uitofp_sext_i32_to_f16(i32 signext %a) nounwind {
; RV64IZFHMIN-LABEL: uitofp_sext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: slli a0, a0, 32
-; RV64IZFHMIN-NEXT: srli a0, a0, 32
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_sext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: slli a0, a0, 32
-; RV64IZHINXMIN-NEXT: srli a0, a0, 32
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = uitofp i32 %a to half
@@ -247,13 +239,13 @@ define half @uitofp_sext_i32_to_f16(i32 signext %a) nounwind {
define half @uitofp_zext_i32_to_f16(i32 zeroext %a) nounwind {
; RV64IZFHMIN-LABEL: uitofp_zext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: fcvt.s.lu fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.wu fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: uitofp_zext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: fcvt.s.lu a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.wu a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = uitofp i32 %a to half
@@ -263,15 +255,13 @@ define half @uitofp_zext_i32_to_f16(i32 zeroext %a) nounwind {
define half @sitofp_aext_i32_to_f16(i32 %a) nounwind {
; RV64IZFHMIN-LABEL: sitofp_aext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: sext.w a0, a0
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_aext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: sext.w a0, a0
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = sitofp i32 %a to half
@@ -281,13 +271,13 @@ define half @sitofp_aext_i32_to_f16(i32 %a) nounwind {
define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind {
; RV64IZFHMIN-LABEL: sitofp_sext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_sext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = sitofp i32 %a to half
@@ -297,15 +287,13 @@ define half @sitofp_sext_i32_to_f16(i32 signext %a) nounwind {
define half @sitofp_zext_i32_to_f16(i32 zeroext %a) nounwind {
; RV64IZFHMIN-LABEL: sitofp_zext_i32_to_f16:
; RV64IZFHMIN: # %bb.0:
-; RV64IZFHMIN-NEXT: sext.w a0, a0
-; RV64IZFHMIN-NEXT: fcvt.s.l fa5, a0
+; RV64IZFHMIN-NEXT: fcvt.s.w fa5, a0
; RV64IZFHMIN-NEXT: fcvt.h.s fa0, fa5
; RV64IZFHMIN-NEXT: ret
;
; RV64IZHINXMIN-LABEL: sitofp_zext_i32_to_f16:
; RV64IZHINXMIN: # %bb.0:
-; RV64IZHINXMIN-NEXT: sext.w a0, a0
-; RV64IZHINXMIN-NEXT: fcvt.s.l a0, a0
+; RV64IZHINXMIN-NEXT: fcvt.s.w a0, a0
; RV64IZHINXMIN-NEXT: fcvt.h.s a0, a0
; RV64IZHINXMIN-NEXT: ret
%1 = sitofp i32 %a to half
>From 129e24b68727fcb88cc23a9ab3e1d0db0809f66f Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 2 Sep 2024 16:06:30 -0700
Subject: [PATCH 2/2] fixup! clang-format
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 24 +++++++++++----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index eb7af7e951a3bf..78cb6b40617c94 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -592,10 +592,10 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
setOperationAction({ISD::FP_TO_UINT_SAT, ISD::FP_TO_SINT_SAT}, XLenVT,
Custom);
- setOperationAction({ISD::STRICT_FP_TO_UINT, ISD::STRICT_FP_TO_SINT},
- XLenVT, Legal);
- setOperationAction({ISD::STRICT_UINT_TO_FP, ISD::STRICT_SINT_TO_FP},
- XLenVT, Custom);
+ setOperationAction({ISD::STRICT_FP_TO_UINT, ISD::STRICT_FP_TO_SINT}, XLenVT,
+ Legal);
+ setOperationAction({ISD::STRICT_UINT_TO_FP, ISD::STRICT_SINT_TO_FP}, XLenVT,
+ Custom);
setOperationAction(ISD::GET_ROUNDING, XLenVT, Custom);
setOperationAction(ISD::SET_ROUNDING, MVT::Other, Custom);
@@ -2968,13 +2968,15 @@ static SDValue lowerINT_TO_FP(SDValue Op, SelectionDAG &DAG,
if (IsStrict) {
SDValue Val = DAG.getNode(Op.getOpcode(), DL, {MVT::f32, MVT::Other},
{Op.getOperand(0), Op.getOperand(1)});
- return DAG.getNode(
- ISD::STRICT_FP_ROUND, DL, {Op.getValueType(), MVT::Other},
- {Val.getValue(1), Val.getValue(0), DAG.getIntPtrConstant(0, DL, /*isTarget=*/true)});
- }
- return DAG.getNode(ISD::FP_ROUND, DL, Op.getValueType(),
- DAG.getNode(Op.getOpcode(), DL, MVT::f32, Op.getOperand(0)),
- DAG.getIntPtrConstant(0, DL, /*isTarget=*/true));
+ return DAG.getNode(ISD::STRICT_FP_ROUND, DL,
+ {Op.getValueType(), MVT::Other},
+ {Val.getValue(1), Val.getValue(0),
+ DAG.getIntPtrConstant(0, DL, /*isTarget=*/true)});
+ }
+ return DAG.getNode(
+ ISD::FP_ROUND, DL, Op.getValueType(),
+ DAG.getNode(Op.getOpcode(), DL, MVT::f32, Op.getOperand(0)),
+ DAG.getIntPtrConstant(0, DL, /*isTarget=*/true));
}
// Other operations are legal.
More information about the llvm-commits
mailing list