mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 10:42:05 +00:00
[RISCV] Refactor extract_subvector lowering slightly. NFC (#65391)
This patch refactors extract_subvector lowering to lower to extract_subreg directly, and to shortcut whenever the index is 0 when extracting a scalable vector. This doesn't change any of the existing behaviour, but makes an upcoming patch that extends the scalable path slightly easier to read.
This commit is contained in:
parent
26181544f7
commit
b46d7011f2
@ -8735,16 +8735,17 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
|
||||
}
|
||||
}
|
||||
|
||||
// With an index of 0 this is a cast-like subvector, which can be performed
|
||||
// with subregister operations.
|
||||
if (OrigIdx == 0)
|
||||
return Op;
|
||||
|
||||
// If the subvector vector is a fixed-length type, we cannot use subregister
|
||||
// manipulation to simplify the codegen; we don't know which register of a
|
||||
// LMUL group contains the specific subvector as we only know the minimum
|
||||
// register size. Therefore we must slide the vector group down the full
|
||||
// amount.
|
||||
if (SubVecVT.isFixedLengthVector()) {
|
||||
// With an index of 0 this is a cast-like subvector, which can be performed
|
||||
// with subregister operations.
|
||||
if (OrigIdx == 0)
|
||||
return Op;
|
||||
MVT ContainerVT = VecVT;
|
||||
if (VecVT.isFixedLengthVector()) {
|
||||
ContainerVT = getContainerForFixedLengthVector(VecVT);
|
||||
@ -8776,17 +8777,18 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
|
||||
if (RemIdx == 0)
|
||||
return Op;
|
||||
|
||||
// Else we must shift our vector register directly to extract the subvector.
|
||||
// Do this using VSLIDEDOWN.
|
||||
// Else SubVecVT is a fractional LMUL and may need to be slid down.
|
||||
assert(RISCVVType::decodeVLMUL(getLMUL(SubVecVT)).second);
|
||||
|
||||
// If the vector type is an LMUL-group type, extract a subvector equal to the
|
||||
// nearest full vector register type. This should resolve to a EXTRACT_SUBREG
|
||||
// instruction.
|
||||
// nearest full vector register type.
|
||||
MVT InterSubVT = VecVT;
|
||||
if (VecVT.bitsGT(getLMUL1VT(VecVT))) {
|
||||
// If VecVT has an LMUL > 1, then SubVecVT should have a smaller LMUL, and
|
||||
// we should have successfully decomposed the extract into a subregister.
|
||||
assert(SubRegIdx != RISCV::NoSubRegister);
|
||||
InterSubVT = getLMUL1VT(VecVT);
|
||||
Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InterSubVT, Vec,
|
||||
DAG.getConstant(OrigIdx - RemIdx, DL, XLenVT));
|
||||
Vec = DAG.getTargetExtractSubreg(SubRegIdx, DL, InterSubVT, Vec);
|
||||
}
|
||||
|
||||
// Slide this vector register down by the desired number of elements in order
|
||||
|
Loading…
Reference in New Issue
Block a user