[llvm] [RISCV] Reduce LMUL when index is known when lowering insert_vector_elt (PR #66087)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 26 08:24:26 PDT 2023
================
@@ -7424,6 +7424,19 @@ SDValue RISCVTargetLowering::lowerINSERT_VECTOR_ELT(SDValue Op,
Vec = convertToScalableVector(ContainerVT, Vec, DAG, Subtarget);
}
+ MVT OrigContainerVT = ContainerVT;
+ SDValue OrigVec = Vec;
+ // If we know the index we're going to insert at, we can shrink Vec so that
+ // we're performing the scalar inserts and slideup on a smaller LMUL.
+ if (auto *CIdx = dyn_cast<ConstantSDNode>(Idx)) {
+ if (auto ShrunkVT = getSmallestVTForIndex(ContainerVT, CIdx->getZExtValue(),
+ DL, DAG, Subtarget)) {
+ ContainerVT = *ShrunkVT;
+ Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ContainerVT, Vec,
----------------
preames wrote:
You also need to update VecVT here. That drives the VL chosen below, and leads to the bug in the test that I had previously pointed out. Having VL=8 with ContainerVT=m1 is not a legal combination. You're very lucky that nothing else is breaking, as the
https://github.com/llvm/llvm-project/pull/66087
More information about the llvm-commits
mailing list