[llvm] [AArch64] Combine SVE shift and truncate into deinterleave (PR #213252)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 06:54:40 PDT 2026
================
@@ -23642,8 +23643,84 @@ static SDValue trySQDMULHCombine(SDNode *N, SelectionDAG &DAG) {
return DAG.getNode(ISD::SIGN_EXTEND, DL, DestVT, SQDMULH);
}
+// Fold a shift by half the source element width followed by a truncation into
+// extraction of the upper half of each source element.
+static SDValue tryShiftTruncateCombine(SDNode *N, SelectionDAG &DAG,
+ TargetLowering::DAGCombinerInfo &DCI) {
+ if (!DCI.isBeforeLegalize())
+ return SDValue();
+
+ EVT DstVT = N->getValueType(0);
+ SDValue Shift = N->getOperand(0);
+
+ if (!DstVT.isScalableVector() || !DstVT.getVectorElementType().isInteger() ||
+ !DAG.getTargetLoweringInfo().isTypeLegal(DstVT))
+ return SDValue();
+
+ if ((Shift.getOpcode() != ISD::SRL && Shift.getOpcode() != ISD::SRA) ||
+ !Shift.hasOneUse())
+ return SDValue();
+
+ EVT SrcVT = Shift.getValueType();
+ if (!SrcVT.isScalableVector() || !SrcVT.getVectorElementType().isInteger() ||
----------------
sdesmalen-arm wrote:
For an SRL/SRA operation, SrcVT/DstVT are guaranteed to be integer types, so this check is redundant.
If DstVT is a scalable vector, we know SrcVT is a scalable vector, so this check is redundant.
https://github.com/llvm/llvm-project/pull/213252
More information about the llvm-commits
mailing list