================
@@ -27545,6 +27545,69 @@ static SDValue
foldExtractSubvectorFromShuffleVector(EVT NarrowVT, SDValue Src,
return DAG.getVectorShuffle(NarrowVT, DL, NewOps[0], NewOps[1], NewMask);
}
+static SDValue foldExtractSubvectorFromConcatVectors(EVT NVT, SDValue V,
+ uint64_t ExtIdx,
+ const SDLoc &DL,
+ SelectionDAG &DAG,
+ bool LegalOperations) {
+ if (V.getOpcode() != ISD::CONCAT_VECTORS)
+ return SDValue();
+
+ unsigned ExtNumElts = NVT.getVectorMinNumElements();
+ EVT ConcatSrcVT = V.getOperand(0).getValueType();
+ assert(ConcatSrcVT.getVectorElementType() == NVT.getVectorElementType() &&
+ "Concat and extract subvector do not change element type");
+
+ unsigned ConcatSrcNumElts = ConcatSrcVT.getVectorMinNumElements();
+ unsigned ConcatOpIdx = ExtIdx / ConcatSrcNumElts;
+ if (ConcatOpIdx >= V.getNumOperands())
+ return SDValue();
+
+ // If the concatenated source types match this extract, it's a direct
+ // simplification:
+ // extract_subvec (concat V1, V2, ...), i --> Vi
+ if (NVT.getVectorElementCount() == ConcatSrcVT.getVectorElementCount())
+ return V.getOperand(ConcatOpIdx);
+
+ if (!NVT.isFixedLengthVector() || !ConcatSrcVT.isFixedLengthVector())
----------------
bjope wrote:
Suggest adding a code comment saying that we only consider fixed length vectors
for the rest of this function.
https://github.com/llvm/llvm-project/pull/200936
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits