[llvm] [DAGCombiner] Add combine for vector interleave of splats (PR #151110)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 03:42:30 PDT 2025


================
@@ -25173,6 +25173,37 @@ static SDValue combineConcatVectorOfCasts(SDNode *N, SelectionDAG &DAG) {
   return DAG.getNode(CastOpcode, DL, VT, NewConcat);
 }
 
+static SDValue combineConcatVectorInterleave(SDNode *N, SelectionDAG &DAG) {
+  SDValue FirstOp = N->getOperand(0);
+  if (FirstOp.getOpcode() != ISD::VECTOR_INTERLEAVE ||
+      FirstOp.getNumOperands() != N->getNumOperands())
+    return SDValue();
+
+  for (unsigned I = 0; I < N->getNumOperands(); I++) {
+    if (N->getOperand(I).getResNo() != I ||
+        N->getOperand(I).getNode() != FirstOp.getNode())
+      return SDValue();
+  }
+
+  if (!llvm::all_equal(FirstOp->op_values()))
+    return SDValue();
+
+  // We're concatenating all the sequential results of the same vector
+  // interleave node. Now check if all inputs to the interleave are splats.
+  SDValue InOp0 = FirstOp.getOperand(0);
+  SDValue Splat = DAG.getSplatValue(InOp0);
+  if (!Splat)
+    return SDValue();
+
+  SDLoc DL(N);
+  EVT SubVecTy = InOp0.getValueType();
+  // Create the wider type required.
+  EVT WideVecTy =
+      EVT::getVectorVT(*DAG.getContext(), SubVecTy.getScalarType(),
+                       SubVecTy.getVectorElementCount() * N->getNumOperands());
----------------
lukel97 wrote:

Is WideVecTy is the same as the concat_vector's type? Can we just replace this with N->getValueType(0) instead?

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


More information about the llvm-commits mailing list