[llvm] [RISCV] Split build_vector into vreg sized pieces when exact VLEN is known (PR #73606)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 22:59:58 PST 2023
================
@@ -3750,6 +3758,38 @@ static SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
if (SDValue Res = lowerBuildVectorViaDominantValues(Op, DAG, Subtarget))
return Res;
+ // If we're compiling for an exact VLEN value, we can split our work per
+ // register in the register group.
+ const unsigned MinVLen = Subtarget.getRealMinVLen();
+ const unsigned MaxVLen = Subtarget.getRealMaxVLen();
+ if (MinVLen == MaxVLen &&
+ VT.getSizeInBits().getKnownMinValue() > MinVLen) {
+ MVT ElemVT = VT.getVectorElementType();
+ unsigned ElemSize = ElemVT.getSizeInBits().getKnownMinValue();
+ unsigned ElemsPerVReg = MinVLen / ElemSize;
+ EVT ContainerVT = getContainerForFixedLengthVector(DAG, VT, Subtarget);
+ MVT OneRegVT = MVT::getVectorVT(ElemVT, ElemsPerVReg);
+ MVT M1VT = getContainerForFixedLengthVector(DAG, OneRegVT, Subtarget);
+ assert(M1VT == getLMUL1VT(M1VT));
+
+ // The following semantically builds up a fixed length concat_vector
+ // of the component build_vectors. We eagerly lower to scalable and
+ // insert_subvector here to avoid DAG combining it back to a large
+ // build_vector.
+ SmallVector<SDValue> BuildVectorOps;
+ BuildVectorOps.append(Op->op_begin(), Op->op_end());
----------------
topperc wrote:
Use the constructor on the SmallVector?
https://github.com/llvm/llvm-project/pull/73606
More information about the llvm-commits
mailing list