Skip to content

Commit 2d50703

Browse files
committed
[RISCV] Use RISCVSubtarget::getRealVLen() in more places. NFC
Catching a couple of more places where we can use the new query added in 8603a7b.
1 parent de41eae commit 2d50703

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,11 +3848,10 @@ static SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
38483848

38493849
// If we're compiling for an exact VLEN value, we can split our work per
38503850
// register in the register group.
3851-
const unsigned MinVLen = Subtarget.getRealMinVLen();
3852-
const unsigned MaxVLen = Subtarget.getRealMaxVLen();
3853-
if (MinVLen == MaxVLen && VT.getSizeInBits().getKnownMinValue() > MinVLen) {
3851+
if (const auto VLen = Subtarget.getRealVLen();
3852+
VLen && VT.getSizeInBits().getKnownMinValue() > *VLen) {
38543853
MVT ElemVT = VT.getVectorElementType();
3855-
unsigned ElemsPerVReg = MinVLen / ElemVT.getFixedSizeInBits();
3854+
unsigned ElemsPerVReg = *VLen / ElemVT.getFixedSizeInBits();
38563855
EVT ContainerVT = getContainerForFixedLengthVector(DAG, VT, Subtarget);
38573856
MVT OneRegVT = MVT::getVectorVT(ElemVT, ElemsPerVReg);
38583857
MVT M1VT = getContainerForFixedLengthVector(DAG, OneRegVT, Subtarget);
@@ -4763,9 +4762,8 @@ static SDValue lowerShuffleViaVRegSplitting(ShuffleVectorSDNode *SVN,
47634762

47644763
// If we don't know exact data layout, not much we can do. If this
47654764
// is already m1 or smaller, no point in splitting further.
4766-
const unsigned MinVLen = Subtarget.getRealMinVLen();
4767-
const unsigned MaxVLen = Subtarget.getRealMaxVLen();
4768-
if (MinVLen != MaxVLen || VT.getSizeInBits().getFixedValue() <= MinVLen)
4765+
const auto VLen = Subtarget.getRealVLen();
4766+
if (!VLen || VT.getSizeInBits().getFixedValue() <= *VLen)
47694767
return SDValue();
47704768

47714769
// Avoid picking up bitrotate patterns which we have a linear-in-lmul
@@ -4776,7 +4774,7 @@ static SDValue lowerShuffleViaVRegSplitting(ShuffleVectorSDNode *SVN,
47764774
return SDValue();
47774775

47784776
MVT ElemVT = VT.getVectorElementType();
4779-
unsigned ElemsPerVReg = MinVLen / ElemVT.getFixedSizeInBits();
4777+
unsigned ElemsPerVReg = *VLen / ElemVT.getFixedSizeInBits();
47804778
unsigned VRegsPerSrc = NumElts / ElemsPerVReg;
47814779

47824780
SmallVector<std::pair<int, SmallVector<int>>>
@@ -8328,15 +8326,13 @@ SDValue RISCVTargetLowering::lowerEXTRACT_VECTOR_ELT(SDValue Op,
83288326
// constant index, we can always perform the extract in m1 (or
83298327
// smaller) as we can determine the register corresponding to
83308328
// the index in the register group.
8331-
const unsigned MinVLen = Subtarget.getRealMinVLen();
8332-
const unsigned MaxVLen = Subtarget.getRealMaxVLen();
8329+
const auto VLen = Subtarget.getRealVLen();
83338330
if (auto *IdxC = dyn_cast<ConstantSDNode>(Idx);
8334-
IdxC && MinVLen == MaxVLen &&
8335-
VecVT.getSizeInBits().getKnownMinValue() > MinVLen) {
8331+
IdxC && VLen && VecVT.getSizeInBits().getKnownMinValue() > *VLen) {
83368332
MVT M1VT = getLMUL1VT(ContainerVT);
83378333
unsigned OrigIdx = IdxC->getZExtValue();
83388334
EVT ElemVT = VecVT.getVectorElementType();
8339-
unsigned ElemsPerVReg = MinVLen / ElemVT.getFixedSizeInBits();
8335+
unsigned ElemsPerVReg = *VLen / ElemVT.getFixedSizeInBits();
83408336
unsigned RemIdx = OrigIdx % ElemsPerVReg;
83418337
unsigned SubRegIdx = OrigIdx / ElemsPerVReg;
83428338
unsigned ExtractIdx =
@@ -9797,15 +9793,14 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
97979793
if (OrigIdx == 0)
97989794
return Op;
97999795

9800-
const unsigned MinVLen = Subtarget.getRealMinVLen();
9801-
const unsigned MaxVLen = Subtarget.getRealMaxVLen();
9796+
const auto VLen = Subtarget.getRealVLen();
98029797

98039798
// If the subvector vector is a fixed-length type and we don't know VLEN
98049799
// exactly, we cannot use subregister manipulation to simplify the codegen; we
98059800
// don't know which register of a LMUL group contains the specific subvector
98069801
// as we only know the minimum register size. Therefore we must slide the
98079802
// vector group down the full amount.
9808-
if (SubVecVT.isFixedLengthVector() && MinVLen != MaxVLen) {
9803+
if (SubVecVT.isFixedLengthVector() && !VLen) {
98099804
MVT ContainerVT = VecVT;
98109805
if (VecVT.isFixedLengthVector()) {
98119806
ContainerVT = getContainerForFixedLengthVector(VecVT);
@@ -9852,8 +9847,8 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
98529847
// and decomposeSubvectorInsertExtractToSubRegs takes this into account. So if
98539848
// we have a fixed length subvector, we need to adjust the index by 1/vscale.
98549849
if (SubVecVT.isFixedLengthVector()) {
9855-
assert(MinVLen == MaxVLen);
9856-
unsigned Vscale = MinVLen / RISCV::RVVBitsPerBlock;
9850+
assert(VLen);
9851+
unsigned Vscale = *VLen / RISCV::RVVBitsPerBlock;
98579852
auto Decompose =
98589853
RISCVTargetLowering::decomposeSubvectorInsertExtractToSubRegs(
98599854
VecVT, ContainerSubVecVT, OrigIdx / Vscale, TRI);

0 commit comments

Comments
 (0)