Skip to content

Commit 54bb229

Browse files
authored
[RISCV] Migrate getConstant indexed insert/extract subvector to new API (#139111)
Note that this change is possibly not NFC. The prior routines used getConstant with XLenVT. The new wrappers will used getVectorIdxConstant instead. Digging through the code, the type used for the index will be the integer of pointer width from DL. For typical RV32 and RV64 configurations the pointer will be of equal width to XLEN, but you could have a 32b pointer on an RV64 machine.
1 parent 8c61bef commit 54bb229

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,8 +2796,7 @@ static SDValue convertFromScalableVector(EVT VT, SDValue V, SelectionDAG &DAG,
27962796
assert(V.getValueType().isScalableVector() &&
27972797
"Expected a scalable vector operand!");
27982798
SDLoc DL(V);
2799-
SDValue Zero = DAG.getConstant(0, DL, Subtarget.getXLenVT());
2800-
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, V, Zero);
2799+
return DAG.getExtractSubvector(DL, VT, V, 0);
28012800
}
28022801

28032802
/// Return the type of the mask type suitable for masking the provided
@@ -3906,8 +3905,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
39063905
// our final mask.
39073906
assert(IntegerViaVecVT == MVT::v1i8 && "Unexpected mask vector type");
39083907
Vec = DAG.getBitcast(MVT::v8i1, Vec);
3909-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Vec,
3910-
DAG.getConstant(0, DL, XLenVT));
3908+
Vec = DAG.getExtractSubvector(DL, VT, Vec, 0);
39113909
} else {
39123910
// Else we must have produced an integer type with the same size as the
39133911
// mask type; bitcast for the final result.
@@ -3970,9 +3968,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
39703968
DAG.getSignedConstant(SplatValue, DL, XLenVT),
39713969
DAG.getVectorIdxConstant(0, DL));
39723970
if (ViaVecLen != 1)
3973-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
3974-
MVT::getVectorVT(ViaIntVT, 1), Vec,
3975-
DAG.getConstant(0, DL, XLenVT));
3971+
Vec = DAG.getExtractSubvector(DL, MVT::getVectorVT(ViaIntVT, 1), Vec, 0);
39763972
return DAG.getBitcast(VT, Vec);
39773973
}
39783974

@@ -4040,9 +4036,8 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
40404036
DAG.getSignedConstant(SplatValue, DL, XLenVT), ViaVL);
40414037
Splat = convertFromScalableVector(ViaVecVT, Splat, DAG, Subtarget);
40424038
if (ViaVecLen != RequiredVL)
4043-
Splat = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
4044-
MVT::getVectorVT(ViaIntVT, RequiredVL), Splat,
4045-
DAG.getConstant(0, DL, XLenVT));
4039+
Splat = DAG.getExtractSubvector(
4040+
DL, MVT::getVectorVT(ViaIntVT, RequiredVL), Splat, 0);
40464041
return DAG.getBitcast(VT, Splat);
40474042
}
40484043
}
@@ -4876,10 +4871,8 @@ static SDValue lowerVECTOR_SHUFFLEAsVSlidedown(const SDLoc &DL, MVT VT,
48764871
getVSlidedown(DAG, Subtarget, DL, ContainerVT, DAG.getUNDEF(ContainerVT),
48774872
convertToScalableVector(ContainerVT, Src, DAG, Subtarget),
48784873
DAG.getConstant(NewMask[0], DL, XLenVT), TrueMask, VL);
4879-
return DAG.getNode(
4880-
ISD::EXTRACT_SUBVECTOR, DL, VT,
4881-
convertFromScalableVector(SrcVT, Slidedown, DAG, Subtarget),
4882-
DAG.getConstant(0, DL, XLenVT));
4874+
return DAG.getExtractSubvector(
4875+
DL, VT, convertFromScalableVector(SrcVT, Slidedown, DAG, Subtarget), 0);
48834876
}
48844877

48854878
// Because vslideup leaves the destination elements at the start intact, we can
@@ -11205,8 +11198,7 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
1120511198
assert(VLen);
1120611199
unsigned Vscale = *VLen / RISCV::RVVBitsPerBlock;
1120711200
SDValue Insert =
11208-
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVecVT, Vec, SubVec,
11209-
DAG.getConstant(OrigIdx / Vscale, DL, XLenVT));
11201+
DAG.getInsertSubvector(DL, Vec, SubVec, OrigIdx / Vscale);
1121011202
if (VecVT.isFixedLengthVector())
1121111203
Insert = convertFromScalableVector(VecVT, Insert, DAG, Subtarget);
1121211204
return Insert;
@@ -11402,8 +11394,8 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
1140211394
if (SubVecVT.isFixedLengthVector()) {
1140311395
assert(VLen);
1140411396
unsigned Vscale = *VLen / RISCV::RVVBitsPerBlock;
11405-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerSubVecVT, Vec,
11406-
DAG.getConstant(OrigIdx / Vscale, DL, XLenVT));
11397+
Vec =
11398+
DAG.getExtractSubvector(DL, ContainerSubVecVT, Vec, OrigIdx / Vscale);
1140711399
return convertFromScalableVector(SubVecVT, Vec, DAG, Subtarget);
1140811400
}
1140911401
return Op;
@@ -11430,8 +11422,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
1143011422
Idx /= *VLen / RISCV::RVVBitsPerBlock;
1143111423
}
1143211424
InterSubVT = getLMUL1VT(VecVT);
11433-
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InterSubVT, Vec,
11434-
DAG.getConstant(Idx, DL, XLenVT));
11425+
Vec = DAG.getExtractSubvector(DL, InterSubVT, Vec, Idx);
1143511426
}
1143611427

1143711428
// Slide this vector register down by the desired number of elements in order

0 commit comments

Comments
 (0)