Skip to content

Commit 6e654ca

Browse files
preameslukel97
andauthored
[DAG] Add wrappers for insert and extract sub-vector [nfc] (#137230)
Mechanical change to introduce the new wrappers, and add enough users to make the usage pattern clear. Once this lands, I'm going to do a further pass to adjust more callsites as separate changes. --------- Co-authored-by: Luke Lau <[email protected]>
1 parent 7548cec commit 6e654ca

File tree

3 files changed

+57
-88
lines changed

3 files changed

+57
-88
lines changed

llvm/include/llvm/CodeGen/SelectionDAG.h

+14
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,20 @@ class SelectionDAG {
924924
/// Example: shuffle A, B, <0,5,2,7> -> shuffle B, A, <4,1,6,3>
925925
SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV);
926926

927+
/// Insert \p SubVec at the \p Idx element of \p Vec.
928+
SDValue getInsertSubvector(const SDLoc &DL, SDValue Vec, SDValue SubVec,
929+
unsigned Idx) {
930+
return getNode(ISD::INSERT_SUBVECTOR, DL, Vec.getValueType(), Vec, SubVec,
931+
getVectorIdxConstant(Idx, DL));
932+
}
933+
934+
/// Return the \p VT typed sub-vector of \p Vec at \p Idx
935+
SDValue getExtractSubvector(const SDLoc &DL, EVT VT, SDValue Vec,
936+
unsigned Idx) {
937+
return getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Vec,
938+
getVectorIdxConstant(Idx, DL));
939+
}
940+
927941
/// Convert Op, which must be of float type, to the
928942
/// float type VT, by either extending or rounding (by truncation).
929943
SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -12674,8 +12674,7 @@ SelectionDAG::matchBinOpReduction(SDNode *Extract, ISD::NodeType &BinOp,
1267412674
if (!TLI->isExtractSubvectorCheap(SubVT, OpVT, 0))
1267512675
return SDValue();
1267612676
BinOp = (ISD::NodeType)CandidateBinOp;
12677-
return getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(Op), SubVT, Op,
12678-
getVectorIdxConstant(0, SDLoc(Op)));
12677+
return getExtractSubvector(SDLoc(Op), SubVT, Op, 0);
1267912678
};
1268012679

1268112680
// At each stage, we're looking for something that looks like:
@@ -13045,8 +13044,7 @@ SelectionDAG::SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT,
1304513044
N.getValueType().getVectorMinNumElements() &&
1304613045
"More vector elements requested than available!");
1304713046
SDValue Lo, Hi;
13048-
Lo =
13049-
getNode(ISD::EXTRACT_SUBVECTOR, DL, LoVT, N, getVectorIdxConstant(0, DL));
13047+
Lo = getExtractSubvector(DL, LoVT, N, 0);
1305013048
// For scalable vectors it is safe to use LoVT.getVectorMinNumElements()
1305113049
// (rather than having to use ElementCount), because EXTRACT_SUBVECTOR scales
1305213050
// IDX with the runtime scaling factor of the result vector type. For
@@ -13078,8 +13076,7 @@ SDValue SelectionDAG::WidenVector(const SDValue &N, const SDLoc &DL) {
1307813076
EVT VT = N.getValueType();
1307913077
EVT WideVT = EVT::getVectorVT(*getContext(), VT.getVectorElementType(),
1308013078
NextPowerOf2(VT.getVectorNumElements()));
13081-
return getNode(ISD::INSERT_SUBVECTOR, DL, WideVT, getUNDEF(WideVT), N,
13082-
getVectorIdxConstant(0, DL));
13079+
return getInsertSubvector(DL, getUNDEF(WideVT), N, 0);
1308313080
}
1308413081

1308513082
void SelectionDAG::ExtractVectorElements(SDValue Op,

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+40-82
Original file line numberDiff line numberDiff line change
@@ -2803,8 +2803,7 @@ static SDValue convertToScalableVector(EVT VT, SDValue V, SelectionDAG &DAG,
28032803
assert(V.getValueType().isFixedLengthVector() &&
28042804
"Expected a fixed length vector operand!");
28052805
SDLoc DL(V);
2806-
SDValue Zero = DAG.getVectorIdxConstant(0, DL);
2807-
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), V, Zero);
2806+
return DAG.getInsertSubvector(DL, DAG.getUNDEF(VT), V, 0);
28082807
}
28092808

28102809
// Shrink V so it's just big enough to maintain a VT's worth of data.
@@ -3648,12 +3647,9 @@ static SDValue matchSplatAsGather(SDValue SplatVal, MVT VT, const SDLoc &DL,
36483647
// Put Vec in a VT sized vector
36493648
if (SrcContainerVT.getVectorMinNumElements() <
36503649
ContainerVT.getVectorMinNumElements())
3651-
Src = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVT,
3652-
DAG.getUNDEF(ContainerVT), Src,
3653-
DAG.getVectorIdxConstant(0, DL));
3650+
Src = DAG.getInsertSubvector(DL, DAG.getUNDEF(ContainerVT), Src, 0);
36543651
else
3655-
Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerVT, Src,
3656-
DAG.getVectorIdxConstant(0, DL));
3652+
Src = DAG.getExtractSubvector(DL, ContainerVT, Src, 0);
36573653

36583654
// We checked that Idx fits inside VT earlier
36593655
auto [Mask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
@@ -4578,17 +4574,14 @@ static SDValue lowerScalarInsert(SDValue Scalar, SDValue VL, MVT VT,
45784574
ExtractedVal, DAG, Subtarget);
45794575
}
45804576
if (ExtractedContainerVT.bitsLE(VT))
4581-
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Passthru,
4582-
ExtractedVal, DAG.getVectorIdxConstant(0, DL));
4583-
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, ExtractedVal,
4584-
DAG.getVectorIdxConstant(0, DL));
4577+
return DAG.getInsertSubvector(DL, Passthru, ExtractedVal, 0);
4578+
return DAG.getExtractSubvector(DL, VT, ExtractedVal, 0);
45854579
}
45864580
}
45874581

4588-
45894582
if (VT.isFloatingPoint())
4590-
return DAG.getNode(RISCVISD::VFMV_S_F_VL, DL, VT,
4591-
DAG.getUNDEF(VT), Scalar, VL);
4583+
return DAG.getNode(RISCVISD::VFMV_S_F_VL, DL, VT, DAG.getUNDEF(VT), Scalar,
4584+
VL);
45924585

45934586
// Avoid the tricky legalization cases by falling back to using the
45944587
// splat code which already handles it gracefully.
@@ -4787,8 +4780,7 @@ static SDValue getDeinterleaveShiftAndTrunc(const SDLoc &DL, MVT VT,
47874780
Res = DAG.getNode(ISD::TRUNCATE, DL, ResVT, Res);
47884781
MVT CastVT = ResVT.changeVectorElementType(VT.getVectorElementType());
47894782
Res = DAG.getBitcast(CastVT, Res);
4790-
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), Res,
4791-
DAG.getVectorIdxConstant(0, DL));
4783+
return DAG.getInsertSubvector(DL, DAG.getUNDEF(VT), Res, 0);
47924784
}
47934785

47944786
/// Match a single source shuffle which is an identity except that some
@@ -5248,8 +5240,7 @@ static SDValue lowerBitreverseShuffle(ShuffleVectorSDNode *SVN,
52485240
// to insert it into the larger vector and then shift up the reversed bits
52495241
// afterwards to get rid of the gap introduced.
52505242
if (ViaEltSize > NumElts)
5251-
V = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ViaBitVT, DAG.getUNDEF(ViaBitVT),
5252-
V, DAG.getVectorIdxConstant(0, DL));
5243+
V = DAG.getInsertSubvector(DL, DAG.getUNDEF(ViaBitVT), V, 0);
52535244

52545245
SDValue Res =
52555246
DAG.getNode(ISD::BITREVERSE, DL, ViaVT, DAG.getBitcast(ViaVT, V));
@@ -5263,8 +5254,7 @@ static SDValue lowerBitreverseShuffle(ShuffleVectorSDNode *SVN,
52635254
Res = DAG.getBitcast(ViaBitVT, Res);
52645255

52655256
if (ViaEltSize > NumElts)
5266-
Res = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res,
5267-
DAG.getVectorIdxConstant(0, DL));
5257+
Res = DAG.getExtractSubvector(DL, VT, Res, 0);
52685258
return Res;
52695259
}
52705260

@@ -5784,8 +5774,7 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
57845774
return Concat;
57855775

57865776
SDValue Vec = DAG.getUNDEF(VT);
5787-
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Vec, Concat,
5788-
DAG.getVectorIdxConstant(0, DL));
5777+
return DAG.getInsertSubvector(DL, Vec, Concat, 0);
57895778
}
57905779
}
57915780
}
@@ -5834,10 +5823,8 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
58345823
// Prefer vzip2a if available.
58355824
// TODO: Extend to matching zip2b if EvenSrc and OddSrc allow.
58365825
if (Subtarget.hasVendorXRivosVizip()) {
5837-
EvenV = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT),
5838-
EvenV, DAG.getVectorIdxConstant(0, DL));
5839-
OddV = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), OddV,
5840-
DAG.getVectorIdxConstant(0, DL));
5826+
EvenV = DAG.getInsertSubvector(DL, DAG.getUNDEF(VT), EvenV, 0);
5827+
OddV = DAG.getInsertSubvector(DL, DAG.getUNDEF(VT), OddV, 0);
58415828
return lowerVZIP(RISCVISD::RI_VZIP2A_VL, EvenV, OddV, DL, DAG, Subtarget);
58425829
}
58435830
return getWideningInterleave(EvenV, OddV, DL, DAG, Subtarget);
@@ -5972,8 +5959,7 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
59725959
if (isSpreadMask(Mask, Factor, Index)) {
59735960
MVT NarrowVT =
59745961
MVT::getVectorVT(VT.getVectorElementType(), NumElts / Factor);
5975-
SDValue Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowVT, V1,
5976-
DAG.getVectorIdxConstant(0, DL));
5962+
SDValue Src = DAG.getExtractSubvector(DL, NarrowVT, V1, 0);
59775963
return getWideningSpread(Src, Factor, Index, DL, DAG);
59785964
}
59795965
}
@@ -5994,12 +5980,10 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
59945980
std::max((uint64_t)MinVLMAX, PowerOf2Ceil(MaxIdx + 1));
59955981
if (NewNumElts != NumElts) {
59965982
MVT NewVT = MVT::getVectorVT(VT.getVectorElementType(), NewNumElts);
5997-
SDValue ZeroIdx = DAG.getVectorIdxConstant(0, DL);
5998-
V1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NewVT, V1, ZeroIdx);
5983+
V1 = DAG.getExtractSubvector(DL, NewVT, V1, 0);
59995984
SDValue Res = DAG.getVectorShuffle(NewVT, DL, V1, DAG.getUNDEF(NewVT),
60005985
Mask.take_front(NewNumElts));
6001-
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), Res,
6002-
ZeroIdx);
5986+
return DAG.getInsertSubvector(DL, DAG.getUNDEF(VT), Res, 0);
60035987
}
60045988
}
60055989

@@ -6151,8 +6135,7 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
61516135
DAG.getUNDEF(IndexContainerVT), LHSIndices,
61526136
SlideAmt, TrueMask, VL);
61536137
SDValue SubIndex =
6154-
DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubIndexVT, LHSIndices,
6155-
DAG.getVectorIdxConstant(0, DL));
6138+
DAG.getExtractSubvector(DL, SubIndexVT, LHSIndices, 0);
61566139
SDValue SubVec =
61576140
DAG.getNode(GatherVVOpc, DL, M1VT, SubV1, SubIndex,
61586141
DAG.getUNDEF(M1VT), InnerTrueMask, InnerVL);
@@ -9951,8 +9934,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_VECTOR_ELT(SDValue Op,
99519934
if (auto SmallerVT =
99529935
getSmallestVTForIndex(ContainerVT, *MaxIdx, DL, DAG, Subtarget)) {
99539936
ContainerVT = *SmallerVT;
9954-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerVT, Vec,
9955-
DAG.getConstant(0, DL, XLenVT));
9937+
Vec = DAG.getExtractSubvector(DL, ContainerVT, Vec, 0);
99569938
}
99579939
}
99589940

@@ -10959,12 +10941,11 @@ static SDValue lowerReductionSeq(unsigned RVVOpcode, MVT ResVT,
1095910941
// prove it is non-zero. For the AVL=0 case, we need the scalar to
1096010942
// be the result of the reduction operation.
1096110943
auto InnerVL = NonZeroAVL ? VL : DAG.getConstant(1, DL, XLenVT);
10962-
SDValue InitialValue = lowerScalarInsert(StartValue, InnerVL, InnerVT, DL,
10963-
DAG, Subtarget);
10944+
SDValue InitialValue =
10945+
lowerScalarInsert(StartValue, InnerVL, InnerVT, DL, DAG, Subtarget);
1096410946
if (M1VT != InnerVT)
1096510947
InitialValue =
10966-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, M1VT, DAG.getUNDEF(M1VT),
10967-
InitialValue, DAG.getVectorIdxConstant(0, DL));
10948+
DAG.getInsertSubvector(DL, DAG.getUNDEF(M1VT), InitialValue, 0);
1096810949
SDValue PassThru = NonZeroAVL ? DAG.getUNDEF(M1VT) : InitialValue;
1096910950
SDValue Policy = DAG.getTargetConstant(RISCVVType::TAIL_AGNOSTIC, DL, XLenVT);
1097010951
SDValue Ops[] = {PassThru, Vec, InitialValue, Mask, VL, Policy};
@@ -11214,9 +11195,7 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1121411195
Vec = convertToScalableVector(ContainerVT, Vec, DAG, Subtarget);
1121511196
}
1121611197

11217-
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVT,
11218-
DAG.getUNDEF(ContainerVT), SubVec,
11219-
DAG.getVectorIdxConstant(0, DL));
11198+
SubVec = DAG.getInsertSubvector(DL, DAG.getUNDEF(ContainerVT), SubVec, 0);
1122011199

1122111200
SDValue Mask =
1122211201
getDefaultVLOps(VecVT, ContainerVT, DL, DAG, Subtarget).first;
@@ -11342,9 +11321,7 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1134211321
DAG.getVectorIdxConstant(AlignedIdx, DL));
1134311322
}
1134411323

11345-
SubVec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, InterSubVT,
11346-
DAG.getUNDEF(InterSubVT), SubVec,
11347-
DAG.getVectorIdxConstant(0, DL));
11324+
SubVec = DAG.getInsertSubvector(DL, DAG.getUNDEF(InterSubVT), SubVec, 0);
1134811325

1134911326
auto [Mask, VL] = getDefaultVLOps(VecVT, ContainerVecVT, DL, DAG, Subtarget);
1135011327

@@ -11458,8 +11435,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
1145811435
if (auto ShrunkVT =
1145911436
getSmallestVTForIndex(ContainerVT, LastIdx, DL, DAG, Subtarget)) {
1146011437
ContainerVT = *ShrunkVT;
11461-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerVT, Vec,
11462-
DAG.getVectorIdxConstant(0, DL));
11438+
Vec = DAG.getExtractSubvector(DL, ContainerVT, Vec, 0);
1146311439
}
1146411440

1146511441
SDValue Mask =
@@ -11472,8 +11448,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
1147211448
getVSlidedown(DAG, Subtarget, DL, ContainerVT,
1147311449
DAG.getUNDEF(ContainerVT), Vec, SlidedownAmt, Mask, VL);
1147411450
// Now we can use a cast-like subvector extract to get the result.
11475-
Slidedown = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubVecVT, Slidedown,
11476-
DAG.getVectorIdxConstant(0, DL));
11451+
Slidedown = DAG.getExtractSubvector(DL, SubVecVT, Slidedown, 0);
1147711452
return DAG.getBitcast(Op.getValueType(), Slidedown);
1147811453
}
1147911454

@@ -11560,8 +11535,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
1156011535

1156111536
// Now the vector is in the right position, extract our final subvector. This
1156211537
// should resolve to a COPY.
11563-
Slidedown = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, SubVecVT, Slidedown,
11564-
DAG.getVectorIdxConstant(0, DL));
11538+
Slidedown = DAG.getExtractSubvector(DL, SubVecVT, Slidedown, 0);
1156511539

1156611540
// We might have bitcast from a mask type: cast back to the original type if
1156711541
// required.
@@ -11664,16 +11638,15 @@ SDValue RISCVTargetLowering::lowerVECTOR_DEINTERLEAVE(SDValue Op,
1166411638
if (SDValue Src = foldConcatVector(V1, V2);
1166511639
Src && getLMUL1VT(VT).bitsGT(VT)) {
1166611640
EVT NewVT = VT.getDoubleNumVectorElementsVT();
11667-
SDValue ZeroIdx = DAG.getVectorIdxConstant(0, DL);
11668-
Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NewVT, Src, ZeroIdx);
11641+
Src = DAG.getExtractSubvector(DL, NewVT, Src, 0);
1166911642
// Freeze the source so we can increase its use count.
1167011643
Src = DAG.getFreeze(Src);
1167111644
SDValue Even = lowerVZIP(RISCVISD::RI_VUNZIP2A_VL, Src,
1167211645
DAG.getUNDEF(NewVT), DL, DAG, Subtarget);
1167311646
SDValue Odd = lowerVZIP(RISCVISD::RI_VUNZIP2B_VL, Src,
1167411647
DAG.getUNDEF(NewVT), DL, DAG, Subtarget);
11675-
Even = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Even, ZeroIdx);
11676-
Odd = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Odd, ZeroIdx);
11648+
Even = DAG.getExtractSubvector(DL, VT, Even, 0);
11649+
Odd = DAG.getExtractSubvector(DL, VT, Odd, 0);
1167711650
return DAG.getMergeValues({Even, Odd}, DL);
1167811651
}
1167911652

@@ -11717,13 +11690,11 @@ SDValue RISCVTargetLowering::lowerVECTOR_DEINTERLEAVE(SDValue Op,
1171711690

1171811691
SDValue EvenSplat = DAG.getConstant(0b01010101, DL, MVT::nxv8i8);
1171911692
EvenSplat = DAG.getBitcast(MVT::nxv64i1, EvenSplat);
11720-
SDValue EvenMask = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, MaskVT,
11721-
EvenSplat, DAG.getVectorIdxConstant(0, DL));
11693+
SDValue EvenMask = DAG.getExtractSubvector(DL, MaskVT, EvenSplat, 0);
1172211694

1172311695
SDValue OddSplat = DAG.getConstant(0b10101010, DL, MVT::nxv8i8);
1172411696
OddSplat = DAG.getBitcast(MVT::nxv64i1, OddSplat);
11725-
SDValue OddMask = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, MaskVT, OddSplat,
11726-
DAG.getVectorIdxConstant(0, DL));
11697+
SDValue OddMask = DAG.getExtractSubvector(DL, MaskVT, OddSplat, 0);
1172711698

1172811699
// vcompress the even and odd elements into two separate vectors
1172911700
SDValue EvenWide = DAG.getNode(ISD::VECTOR_COMPRESS, DL, ConcatVT, Concat,
@@ -12103,9 +12074,7 @@ SDValue RISCVTargetLowering::lowerVECTOR_REVERSE(SDValue Op,
1210312074
Hi = DAG.getNode(ISD::VECTOR_REVERSE, DL, HiVT, Hi);
1210412075
// Reassemble the low and high pieces reversed.
1210512076
// FIXME: This is a CONCAT_VECTORS.
12106-
SDValue Res =
12107-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VecVT, DAG.getUNDEF(VecVT), Hi,
12108-
DAG.getVectorIdxConstant(0, DL));
12077+
SDValue Res = DAG.getInsertSubvector(DL, DAG.getUNDEF(VecVT), Hi, 0);
1210912078
return DAG.getNode(
1211012079
ISD::INSERT_SUBVECTOR, DL, VecVT, Res, Lo,
1211112080
DAG.getVectorIdxConstant(LoVT.getVectorMinNumElements(), DL));
@@ -12254,8 +12223,7 @@ RISCVTargetLowering::lowerFixedLengthVectorStoreToRVV(SDValue Op,
1225412223
if (VT.getVectorElementType() == MVT::i1 && VT.getVectorNumElements() < 8) {
1225512224
VT = MVT::v8i1;
1225612225
StoreVal =
12257-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getConstant(0, DL, VT),
12258-
StoreVal, DAG.getVectorIdxConstant(0, DL));
12226+
DAG.getInsertSubvector(DL, DAG.getConstant(0, DL, VT), StoreVal, 0);
1225912227
}
1226012228

1226112229
MVT ContainerVT = getContainerForFixedLengthVector(VT);
@@ -14687,8 +14655,7 @@ static SDValue combineBinOpToReduce(SDNode *N, SelectionDAG &DAG,
1468714655
// If we looked through an INSERT_SUBVECTOR we need to restore it.
1468814656
if (ScalarVT != ScalarV.getValueType())
1468914657
NewScalarV =
14690-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ScalarVT, DAG.getUNDEF(ScalarVT),
14691-
NewScalarV, DAG.getVectorIdxConstant(0, DL));
14658+
DAG.getInsertSubvector(DL, DAG.getUNDEF(ScalarVT), NewScalarV, 0);
1469214659

1469314660
SDValue Ops[] = {Reduce.getOperand(0), Reduce.getOperand(1),
1469414661
NewScalarV, Reduce.getOperand(3),
@@ -19966,13 +19933,10 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
1996619933
// Use M1 or smaller to avoid over constraining register allocation
1996719934
const MVT M1VT = getLMUL1VT(VT);
1996819935
if (M1VT.bitsLT(VT)) {
19969-
SDValue M1Passthru =
19970-
DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, M1VT, Passthru,
19971-
DAG.getVectorIdxConstant(0, DL));
19936+
SDValue M1Passthru = DAG.getExtractSubvector(DL, M1VT, Passthru, 0);
1997219937
SDValue Result =
1997319938
DAG.getNode(N->getOpcode(), DL, M1VT, M1Passthru, Scalar, VL);
19974-
Result = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, Passthru, Result,
19975-
DAG.getVectorIdxConstant(0, DL));
19939+
Result = DAG.getInsertSubvector(DL, Passthru, Result, 0);
1997619940
return Result;
1997719941
}
1997819942

@@ -19991,8 +19955,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
1999119955
MVT VecVT = N->getOperand(0).getSimpleValueType();
1999219956
const MVT M1VT = getLMUL1VT(VecVT);
1999319957
if (M1VT.bitsLT(VecVT)) {
19994-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, M1VT, Vec,
19995-
DAG.getVectorIdxConstant(0, DL));
19958+
Vec = DAG.getExtractSubvector(DL, M1VT, Vec, 0);
1999619959
return DAG.getNode(RISCVISD::VMV_X_S, DL, N->getSimpleValueType(0), Vec);
1999719960
}
1999819961
break;
@@ -23631,15 +23594,11 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
2363123594
assert(Count != 0 && "The number of element should not be zero.");
2363223595
EVT SameEltTypeVT =
2363323596
EVT::getVectorVT(Context, ValueEltVT, Count, /*IsScalable=*/true);
23634-
Val = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, SameEltTypeVT,
23635-
DAG.getUNDEF(SameEltTypeVT), Val,
23636-
DAG.getVectorIdxConstant(0, DL));
23597+
Val = DAG.getInsertSubvector(DL, DAG.getUNDEF(SameEltTypeVT), Val, 0);
2363723598
}
2363823599
Val = DAG.getNode(ISD::BITCAST, DL, PartVT, Val);
2363923600
} else {
23640-
Val =
23641-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, PartVT, DAG.getUNDEF(PartVT),
23642-
Val, DAG.getVectorIdxConstant(0, DL));
23601+
Val = DAG.getInsertSubvector(DL, DAG.getUNDEF(PartVT), Val, 0);
2364323602
}
2364423603
Parts[0] = Val;
2364523604
return true;
@@ -23708,8 +23667,7 @@ SDValue RISCVTargetLowering::joinRegisterPartsIntoValue(
2370823667
EVT::getVectorVT(Context, ValueEltVT, Count, /*IsScalable=*/true);
2370923668
Val = DAG.getNode(ISD::BITCAST, DL, SameEltTypeVT, Val);
2371023669
}
23711-
Val = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ValueVT, Val,
23712-
DAG.getVectorIdxConstant(0, DL));
23670+
Val = DAG.getExtractSubvector(DL, ValueVT, Val, 0);
2371323671
return Val;
2371423672
}
2371523673
}

0 commit comments

Comments
 (0)