@@ -8735,16 +8735,17 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
8735
8735
}
8736
8736
}
8737
8737
8738
+ // With an index of 0 this is a cast-like subvector, which can be performed
8739
+ // with subregister operations.
8740
+ if (OrigIdx == 0)
8741
+ return Op;
8742
+
8738
8743
// If the subvector vector is a fixed-length type, we cannot use subregister
8739
8744
// manipulation to simplify the codegen; we don't know which register of a
8740
8745
// LMUL group contains the specific subvector as we only know the minimum
8741
8746
// register size. Therefore we must slide the vector group down the full
8742
8747
// amount.
8743
8748
if (SubVecVT.isFixedLengthVector()) {
8744
- // With an index of 0 this is a cast-like subvector, which can be performed
8745
- // with subregister operations.
8746
- if (OrigIdx == 0)
8747
- return Op;
8748
8749
MVT ContainerVT = VecVT;
8749
8750
if (VecVT.isFixedLengthVector()) {
8750
8751
ContainerVT = getContainerForFixedLengthVector(VecVT);
@@ -8776,17 +8777,18 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
8776
8777
if (RemIdx == 0)
8777
8778
return Op;
8778
8779
8779
- // Else we must shift our vector register directly to extract the subvector .
8780
- // Do this using VSLIDEDOWN.
8780
+ // Else SubVecVT is a fractional LMUL and may need to be slid down .
8781
+ assert(RISCVVType::decodeVLMUL(getLMUL(SubVecVT)).second);
8781
8782
8782
8783
// If the vector type is an LMUL-group type, extract a subvector equal to the
8783
- // nearest full vector register type. This should resolve to a EXTRACT_SUBREG
8784
- // instruction.
8784
+ // nearest full vector register type.
8785
8785
MVT InterSubVT = VecVT;
8786
8786
if (VecVT.bitsGT(getLMUL1VT(VecVT))) {
8787
+ // If VecVT has an LMUL > 1, then SubVecVT should have a smaller LMUL, and
8788
+ // we should have successfully decomposed the extract into a subregister.
8789
+ assert(SubRegIdx != RISCV::NoSubRegister);
8787
8790
InterSubVT = getLMUL1VT(VecVT);
8788
- Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InterSubVT, Vec,
8789
- DAG.getConstant(OrigIdx - RemIdx, DL, XLenVT));
8791
+ Vec = DAG.getTargetExtractSubreg(SubRegIdx, DL, InterSubVT, Vec);
8790
8792
}
8791
8793
8792
8794
// Slide this vector register down by the desired number of elements in order
0 commit comments