Skip to content

[RISCV] Migrate getConstant indexed insert/extract subvector to new API #139111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2796,8 +2796,7 @@ static SDValue convertFromScalableVector(EVT VT, SDValue V, SelectionDAG &DAG,
assert(V.getValueType().isScalableVector() &&
"Expected a scalable vector operand!");
SDLoc DL(V);
SDValue Zero = DAG.getConstant(0, DL, Subtarget.getXLenVT());
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, V, Zero);
return DAG.getExtractSubvector(DL, VT, V, 0);
}

/// Return the type of the mask type suitable for masking the provided
Expand Down Expand Up @@ -3906,8 +3905,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
// our final mask.
assert(IntegerViaVecVT == MVT::v1i8 && "Unexpected mask vector type");
Vec = DAG.getBitcast(MVT::v8i1, Vec);
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Vec,
DAG.getConstant(0, DL, XLenVT));
Vec = DAG.getExtractSubvector(DL, VT, Vec, 0);
} else {
// Else we must have produced an integer type with the same size as the
// mask type; bitcast for the final result.
Expand Down Expand Up @@ -3970,9 +3968,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
DAG.getSignedConstant(SplatValue, DL, XLenVT),
DAG.getVectorIdxConstant(0, DL));
if (ViaVecLen != 1)
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
MVT::getVectorVT(ViaIntVT, 1), Vec,
DAG.getConstant(0, DL, XLenVT));
Vec = DAG.getExtractSubvector(DL, MVT::getVectorVT(ViaIntVT, 1), Vec, 0);
return DAG.getBitcast(VT, Vec);
}

Expand Down Expand Up @@ -4040,9 +4036,8 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
DAG.getSignedConstant(SplatValue, DL, XLenVT), ViaVL);
Splat = convertFromScalableVector(ViaVecVT, Splat, DAG, Subtarget);
if (ViaVecLen != RequiredVL)
Splat = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL,
MVT::getVectorVT(ViaIntVT, RequiredVL), Splat,
DAG.getConstant(0, DL, XLenVT));
Splat = DAG.getExtractSubvector(
DL, MVT::getVectorVT(ViaIntVT, RequiredVL), Splat, 0);
return DAG.getBitcast(VT, Splat);
}
}
Expand Down Expand Up @@ -4876,10 +4871,8 @@ static SDValue lowerVECTOR_SHUFFLEAsVSlidedown(const SDLoc &DL, MVT VT,
getVSlidedown(DAG, Subtarget, DL, ContainerVT, DAG.getUNDEF(ContainerVT),
convertToScalableVector(ContainerVT, Src, DAG, Subtarget),
DAG.getConstant(NewMask[0], DL, XLenVT), TrueMask, VL);
return DAG.getNode(
ISD::EXTRACT_SUBVECTOR, DL, VT,
convertFromScalableVector(SrcVT, Slidedown, DAG, Subtarget),
DAG.getConstant(0, DL, XLenVT));
return DAG.getExtractSubvector(
DL, VT, convertFromScalableVector(SrcVT, Slidedown, DAG, Subtarget), 0);
}

// Because vslideup leaves the destination elements at the start intact, we can
Expand Down Expand Up @@ -11205,8 +11198,7 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
assert(VLen);
unsigned Vscale = *VLen / RISCV::RVVBitsPerBlock;
SDValue Insert =
DAG.getNode(ISD::INSERT_SUBVECTOR, DL, ContainerVecVT, Vec, SubVec,
DAG.getConstant(OrigIdx / Vscale, DL, XLenVT));
DAG.getInsertSubvector(DL, Vec, SubVec, OrigIdx / Vscale);
if (VecVT.isFixedLengthVector())
Insert = convertFromScalableVector(VecVT, Insert, DAG, Subtarget);
return Insert;
Expand Down Expand Up @@ -11402,8 +11394,8 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
if (SubVecVT.isFixedLengthVector()) {
assert(VLen);
unsigned Vscale = *VLen / RISCV::RVVBitsPerBlock;
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerSubVecVT, Vec,
DAG.getConstant(OrigIdx / Vscale, DL, XLenVT));
Vec =
DAG.getExtractSubvector(DL, ContainerSubVecVT, Vec, OrigIdx / Vscale);
return convertFromScalableVector(SubVecVT, Vec, DAG, Subtarget);
}
return Op;
Expand All @@ -11430,8 +11422,7 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
Idx /= *VLen / RISCV::RVVBitsPerBlock;
}
InterSubVT = getLMUL1VT(VecVT);
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InterSubVT, Vec,
DAG.getConstant(Idx, DL, XLenVT));
Vec = DAG.getExtractSubvector(DL, InterSubVT, Vec, Idx);
}

// Slide this vector register down by the desired number of elements in order
Expand Down
Loading