[llvm] [DAGCombiner] Add combine for vector interleave of splats (PR #151110)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 07:48:28 PDT 2025
================
@@ -25173,6 +25173,38 @@ 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();
+ }
+
+ SDValue InOp0 = FirstOp.getOperand(0);
+ if (!llvm::all_of(FirstOp->ops(),
+ [&InOp0](SDValue Op) { return Op == InOp0; }))
+ 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.
+ if (SDValue Splat = DAG.getSplatValue(InOp0)) {
----------------
lukel97 wrote:
Nit, early return instead?
```suggestion
SDValue Splat = DAG.getSplatValue(InOp0);
if (!Splat)
return SDValue();
```
https://github.com/llvm/llvm-project/pull/151110
More information about the llvm-commits
mailing list