[llvm] [RISCV] Lower SEW<=32 vector_deinterleave(2) via vunzip2{a, b} (PR #136463)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 20 20:35:04 PDT 2025
================
@@ -4569,36 +4569,48 @@ static SDValue lowerScalarInsert(SDValue Scalar, SDValue VL, MVT VT,
VL);
}
-// Can this shuffle be performed on exactly one (possibly larger) input?
-static SDValue getSingleShuffleSrc(MVT VT, SDValue V1, SDValue V2) {
-
- if (V2.isUndef())
- return V1;
-
+/// If concat_vector(V1,V2) could be folded away to some existing
+/// vector source, return it. Note that the source may be larger
+/// than the requested concat_vector (i.e. a extract_subvector
+/// might be required.)
+static SDValue FoldConcatVector(SDValue V1, SDValue V2) {
+ EVT VT = V1.getValueType();
+ assert(VT == V1.getValueType() && "precondition");
// Both input must be extracts.
if (V1.getOpcode() != ISD::EXTRACT_SUBVECTOR ||
V2.getOpcode() != ISD::EXTRACT_SUBVECTOR)
return SDValue();
// Extracting from the same source.
SDValue Src = V1.getOperand(0);
- if (Src != V2.getOperand(0))
- return SDValue();
-
- // Src needs to have twice the number of elements.
- unsigned NumElts = VT.getVectorNumElements();
- if (!Src.getValueType().isFixedLengthVector() ||
- Src.getValueType().getVectorNumElements() != (NumElts * 2))
+ if (Src != V2.getOperand(0) ||
+ VT.isScalableVector() != Src.getValueType().isScalableVector())
return SDValue();
// The extracts must extract the two halves of the source.
if (V1.getConstantOperandVal(1) != 0 ||
- V2.getConstantOperandVal(1) != NumElts)
+ V2.getConstantOperandVal(1) != VT.getVectorMinNumElements())
return SDValue();
return Src;
}
+// Can this shuffle be performed on exactly one (possibly larger) input?
+static SDValue getSingleShuffleSrc(MVT VT, SDValue V1, SDValue V2) {
+
+ if (V2.isUndef())
+ return V1;
+
+ unsigned NumElts = VT.getVectorNumElements();
+ // Src needs to have twice the number of elements.
+ // TODO: Update shuffle lowering to add the extract subvector
+ if (SDValue Src = FoldConcatVector(V1, V2);
+ Src && Src.getValueType().getVectorNumElements() == (NumElts * 2))
----------------
lukel97 wrote:
Do we need to add back the isFixedLengthVector() check here?
https://github.com/llvm/llvm-project/pull/136463
More information about the llvm-commits
mailing list