[llvm] 0501c16 - [X86] Add isFreeToSplitVector helper to detect nodes that we can freely split/extract subvectors from.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 07:27:58 PDT 2023
Author: Simon Pilgrim
Date: 2023-06-29T15:27:40+01:00
New Revision: 0501c1603f5dbbd81627ee1c25cff470b867a13f
URL: https://github.com/llvm/llvm-project/commit/0501c1603f5dbbd81627ee1c25cff470b867a13f
DIFF: https://github.com/llvm/llvm-project/commit/0501c1603f5dbbd81627ee1c25cff470b867a13f.diff
LOG: [X86] Add isFreeToSplitVector helper to detect nodes that we can freely split/extract subvectors from.
Helper wrapper around the existing collectConcatOps method.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 85ed811a631ec..c5c12ffd9166e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -6763,6 +6763,13 @@ static bool collectConcatOps(SDNode *N, SmallVectorImpl<SDValue> &Ops,
return false;
}
+// Helper to check if we can access all the constituent subvectors without any
+// extract ops.
+static bool isFreeToSplitVector(SDNode *N, SelectionDAG &DAG) {
+ SmallVector<SDValue> Ops;
+ return collectConcatOps(N, Ops, DAG);
+}
+
static std::pair<SDValue, SDValue> splitVector(SDValue Op, SelectionDAG &DAG,
const SDLoc &dl) {
EVT VT = Op.getValueType();
@@ -26904,9 +26911,7 @@ static SDValue LowerStore(SDValue Op, const X86Subtarget &Subtarget,
if (StoreVT.is256BitVector() ||
((StoreVT == MVT::v32i16 || StoreVT == MVT::v64i8) &&
!Subtarget.hasBWI())) {
- SmallVector<SDValue, 4> CatOps;
- if (StoredVal.hasOneUse() &&
- collectConcatOps(StoredVal.getNode(), CatOps, DAG))
+ if (StoredVal.hasOneUse() && isFreeToSplitVector(StoredVal.getNode(), DAG))
return splitVectorStore(St, DAG);
return SDValue();
}
@@ -46587,10 +46592,9 @@ static SDValue narrowVectorSelect(SDNode *N, SelectionDAG &DAG,
SDValue Cond = N->getOperand(0);
SDValue TVal = N->getOperand(1);
SDValue FVal = N->getOperand(2);
- SmallVector<SDValue, 4> CatOpsT, CatOpsF;
if (!TVal.hasOneUse() || !FVal.hasOneUse() ||
- !collectConcatOps(TVal.getNode(), CatOpsT, DAG) ||
- !collectConcatOps(FVal.getNode(), CatOpsF, DAG))
+ !isFreeToSplitVector(TVal.getNode(), DAG) ||
+ !isFreeToSplitVector(FVal.getNode(), DAG))
return SDValue();
auto makeBlend = [Opcode](SelectionDAG &DAG, const SDLoc &DL,
@@ -53160,9 +53164,7 @@ static SDValue combineVectorSignBitsTruncation(SDNode *N, const SDLoc &DL,
InVT.is512BitVector())) {
// PACK should still be worth it for 128-bit vectors if the sources were
// originally concatenated from subvectors.
- SmallVector<SDValue> ConcatOps;
- if (VT.getSizeInBits() > 128 ||
- !collectConcatOps(In.getNode(), ConcatOps, DAG))
+ if (VT.getSizeInBits() > 128 || !isFreeToSplitVector(In.getNode(), DAG))
return SDValue();
}
@@ -57280,9 +57282,8 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
/// to get simple value types will assert).
static SDValue narrowExtractedVectorSelect(SDNode *Ext, SelectionDAG &DAG) {
SDValue Sel = Ext->getOperand(0);
- SmallVector<SDValue, 4> CatOps;
if (Sel.getOpcode() != ISD::VSELECT ||
- !collectConcatOps(Sel.getOperand(0).getNode(), CatOps, DAG))
+ !isFreeToSplitVector(Sel.getOperand(0).getNode(), DAG))
return SDValue();
// Note: We assume simple value types because this should only be called with
More information about the llvm-commits
mailing list