[llvm] [RISCV] Extract subregister if VLEN is known when lowering extract_subvector (PR #65392)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 13:04:01 PDT 2023
================
@@ -8653,36 +8656,68 @@ SDValue RISCVTargetLowering::lowerEXTRACT_SUBVECTOR(SDValue Op,
return DAG.getBitcast(Op.getValueType(), Slidedown);
}
+ if (VecVT.isFixedLengthVector()) {
+ VecVT = getContainerForFixedLengthVector(VecVT);
+ Vec = convertToScalableVector(VecVT, Vec, DAG, Subtarget);
+ }
+
+ // The semantics of extract_subvector are that if the extracted subvector is
+ // scalable, then the index is scaled by vscale. So if we have a fixed length
+ // subvector, we need to factor that in before we decompose it to
+ // subregisters...
+ MVT ContainerSubVecVT = SubVecVT;
+ unsigned EffectiveIdx = OrigIdx;
+ unsigned Vscale = *KnownVLen / RISCV::RVVBitsPerBlock;
+ if (SubVecVT.isFixedLengthVector()) {
+ assert(KnownVLen);
----------------
lukel97 wrote:
IIUC `*` on a null optional is just UB, you need to use `value()` to have an exception thrown. This part is a bit hairy though, I'm avoiding `value()` so I don't have to define `Vscale` twice. Any ideas on a better way to structure this?
https://github.com/llvm/llvm-project/pull/65392
More information about the llvm-commits
mailing list