[PATCH] D120735: [DAGCombine] Prevent illegal ISD::SPLAT_VECTOR operations post legalisation.
Paul Walker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 4 03:56:10 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42b4a6227e3e: [DAGCombine] Prevent illegal ISD::SPLAT_VECTOR operations post legalisation. (authored by paulwalker-arm).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120735/new/
https://reviews.llvm.org/D120735
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -871,6 +871,7 @@
setTargetDAGCombine(ISD::VECTOR_SPLICE);
setTargetDAGCombine(ISD::SIGN_EXTEND_INREG);
setTargetDAGCombine(ISD::CONCAT_VECTORS);
+ setTargetDAGCombine(ISD::EXTRACT_SUBVECTOR);
setTargetDAGCombine(ISD::INSERT_SUBVECTOR);
setTargetDAGCombine(ISD::STORE);
if (Subtarget->supportsAddressTopByteIgnored())
@@ -14472,6 +14473,29 @@
RHS));
}
+static SDValue
+performExtractSubvectorCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
+ SelectionDAG &DAG) {
+ if (DCI.isBeforeLegalizeOps())
+ return SDValue();
+
+ EVT VT = N->getValueType(0);
+ if (!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1)
+ return SDValue();
+
+ SDValue V = N->getOperand(0);
+
+ // NOTE: This combine exists in DAGCombiner, but that version's legality check
+ // blocks this combine because the non-const case requires custom lowering.
+ //
+ // ty1 extract_vector(ty2 splat(const))) -> ty1 splat(const)
+ if (V.getOpcode() == ISD::SPLAT_VECTOR)
+ if (isa<ConstantSDNode>(V.getOperand(0)))
+ return DAG.getNode(ISD::SPLAT_VECTOR, SDLoc(N), VT, V.getOperand(0));
+
+ return SDValue();
+}
+
static SDValue
performInsertSubvectorCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
SelectionDAG &DAG) {
@@ -18181,6 +18205,8 @@
return performSignExtendInRegCombine(N, DCI, DAG);
case ISD::CONCAT_VECTORS:
return performConcatVectorsCombine(N, DCI, DAG);
+ case ISD::EXTRACT_SUBVECTOR:
+ return performExtractSubvectorCombine(N, DCI, DAG);
case ISD::INSERT_SUBVECTOR:
return performInsertSubvectorCombine(N, DCI, DAG);
case ISD::SELECT:
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -21260,7 +21260,8 @@
// ty1 extract_vector(ty2 splat(V))) -> ty1 splat(V)
if (V.getOpcode() == ISD::SPLAT_VECTOR)
if (DAG.isConstantValueOfAnyType(V.getOperand(0)) || V.hasOneUse())
- return DAG.getSplatVector(NVT, SDLoc(N), V.getOperand(0));
+ if (!LegalOperations || TLI.isOperationLegal(ISD::SPLAT_VECTOR, NVT))
+ return DAG.getSplatVector(NVT, SDLoc(N), V.getOperand(0));
// Try to move vector bitcast after extract_subv by scaling extraction index:
// extract_subv (bitcast X), Index --> bitcast (extract_subv X, Index')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120735.412977.patch
Type: text/x-patch
Size: 2729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220304/13999a90/attachment.bin>
More information about the llvm-commits
mailing list