[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
Wed Sep 27 11:38:04 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:

See https://github.com/llvm/llvm-project/pull/66087#discussion_r1339046777, we're discussing the same issue in two different parts of the review.  

https://github.com/llvm/llvm-project/pull/66087


More information about the llvm-commits mailing list