@@ -10152,13 +10152,15 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1015210152 unsigned OrigIdx = Op.getConstantOperandVal(2);
1015310153 const RISCVRegisterInfo *TRI = Subtarget.getRegisterInfo();
1015410154
10155+ if (OrigIdx == 0 && Vec.isUndef())
10156+ return Op;
10157+
1015510158 // We don't have the ability to slide mask vectors up indexed by their i1
1015610159 // elements; the smallest we can do is i8. Often we are able to bitcast to
1015710160 // equivalent i8 vectors. Note that when inserting a fixed-length vector
1015810161 // into a scalable one, we might not necessarily have enough scalable
1015910162 // elements to safely divide by 8: nxv1i1 = insert nxv1i1, v4i1 is valid.
10160- if (SubVecVT.getVectorElementType() == MVT::i1 &&
10161- (OrigIdx != 0 || !Vec.isUndef())) {
10163+ if (SubVecVT.getVectorElementType() == MVT::i1) {
1016210164 if (VecVT.getVectorMinNumElements() >= 8 &&
1016310165 SubVecVT.getVectorMinNumElements() >= 8) {
1016410166 assert(OrigIdx % 8 == 0 && "Invalid index");
@@ -10196,8 +10198,6 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1019610198 // vector group up the full amount.
1019710199 const auto VLen = Subtarget.getRealVLen();
1019810200 if (SubVecVT.isFixedLengthVector() && !VLen) {
10199- if (OrigIdx == 0 && Vec.isUndef() && !VecVT.isFixedLengthVector())
10200- return Op;
1020110201 MVT ContainerVT = VecVT;
1020210202 if (VecVT.isFixedLengthVector()) {
1020310203 ContainerVT = getContainerForFixedLengthVector(VecVT);
@@ -10208,11 +10208,6 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1020810208 DAG.getUNDEF(ContainerVT), SubVec,
1020910209 DAG.getVectorIdxConstant(0, DL));
1021010210
10211- if (OrigIdx == 0 && Vec.isUndef() && VecVT.isFixedLengthVector()) {
10212- SubVec = convertFromScalableVector(VecVT, SubVec, DAG, Subtarget);
10213- return DAG.getBitcast(Op.getValueType(), SubVec);
10214- }
10215-
1021610211 SDValue Mask =
1021710212 getDefaultVLOps(VecVT, ContainerVT, DL, DAG, Subtarget).first;
1021810213 // Set the vector length to only the number of elements we care about. Note
0 commit comments