@@ -1076,9 +1076,10 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
1076
1076
setOperationAction({ISD::SINT_TO_FP, ISD::UINT_TO_FP, ISD::VP_SINT_TO_FP,
1077
1077
ISD::VP_UINT_TO_FP},
1078
1078
VT, Custom);
1079
- setOperationAction({ISD::CONCAT_VECTORS, ISD::INSERT_SUBVECTOR,
1080
- ISD::EXTRACT_SUBVECTOR, ISD::VECTOR_DEINTERLEAVE,
1081
- ISD::VECTOR_INTERLEAVE, ISD::VECTOR_REVERSE},
1079
+ setOperationAction({ISD::INSERT_VECTOR_ELT, ISD::CONCAT_VECTORS,
1080
+ ISD::INSERT_SUBVECTOR, ISD::EXTRACT_SUBVECTOR,
1081
+ ISD::VECTOR_DEINTERLEAVE, ISD::VECTOR_INTERLEAVE,
1082
+ ISD::VECTOR_REVERSE},
1082
1083
VT, Custom);
1083
1084
MVT EltVT = VT.getVectorElementType();
1084
1085
if (isTypeLegal(EltVT))
@@ -8756,8 +8757,10 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
8756
8757
SelectionDAG &DAG) const {
8757
8758
SDLoc DL(Op);
8758
8759
MVT VecVT = Op.getSimpleValueType();
8760
+ MVT XLenVT = Subtarget.getXLenVT();
8759
8761
SDValue Vec = Op.getOperand(0);
8760
8762
SDValue Val = Op.getOperand(1);
8763
+ MVT ValVT = Val.getSimpleValueType();
8761
8764
SDValue Idx = Op.getOperand(2);
8762
8765
8763
8766
if (VecVT.getVectorElementType() == MVT::i1) {
@@ -8769,6 +8772,17 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
8769
8772
return DAG.getNode(ISD::TRUNCATE, DL, VecVT, Vec);
8770
8773
}
8771
8774
8775
+ if ((ValVT == MVT::f16 && !Subtarget.hasVInstructionsF16()) ||
8776
+ ValVT == MVT::bf16) {
8777
+ // If we don't have vfmv.s.f for f16/bf16, insert into fmv.x.h first
8778
+ MVT IntVT = VecVT.changeTypeToInteger();
8779
+ // SDValue IntVal = DAG.getBitcast(IntVT.getVectorElementType(), Val);
8780
+ SDValue IntInsert = DAG.getNode(
8781
+ ISD::INSERT_VECTOR_ELT, DL, IntVT, DAG.getBitcast(IntVT, Vec),
8782
+ DAG.getNode(RISCVISD::FMV_X_ANYEXTH, DL, XLenVT, Val), Idx);
8783
+ return DAG.getBitcast(VecVT, IntInsert);
8784
+ }
8785
+
8772
8786
MVT ContainerVT = VecVT;
8773
8787
// If the operand is a fixed-length vector, convert to a scalable one.
8774
8788
if (VecVT.isFixedLengthVector()) {
@@ -8812,8 +8826,6 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
8812
8826
AlignedIdx);
8813
8827
}
8814
8828
8815
- MVT XLenVT = Subtarget.getXLenVT();
8816
-
8817
8829
bool IsLegalInsert = Subtarget.is64Bit() || Val.getValueType() != MVT::i64;
8818
8830
// Even i64-element vectors on RV32 can be lowered without scalar
8819
8831
// legalization if the most-significant 32 bits of the value are not affected
0 commit comments