Skip to content

Commit db4dc88

Browse files
authored
[X86] combineEXTRACT_SUBVECTOR - remove unnecessary bitcast handling. (#145496)
We already aggressively fold extract_subvector(bitcast()) -> bitcast(extract_subvector())
1 parent 9f3931b commit db4dc88

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59577,7 +59577,6 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5957759577
MVT VT = N->getSimpleValueType(0);
5957859578
SDValue InVec = N->getOperand(0);
5957959579
unsigned IdxVal = N->getConstantOperandVal(1);
59580-
SDValue InVecBC = peekThroughBitcasts(InVec);
5958159580
EVT InVecVT = InVec.getValueType();
5958259581
unsigned SizeInBits = VT.getSizeInBits();
5958359582
unsigned InSizeInBits = InVecVT.getSizeInBits();
@@ -59594,20 +59593,20 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5959459593
// This pattern emerges during AVX1 legalization. We handle it before lowering
5959559594
// to avoid complications like splitting constant vector loads.
5959659595
if (Subtarget.hasAVX() && !Subtarget.hasAVX2() && TLI.isTypeLegal(InVecVT) &&
59597-
InSizeInBits == 256 && InVecBC.getOpcode() == ISD::AND) {
59596+
InSizeInBits == 256 && InVec.getOpcode() == ISD::AND) {
5959859597
auto isConcatenatedNot = [](SDValue V) {
5959959598
V = peekThroughBitcasts(V);
5960059599
if (!isBitwiseNot(V))
5960159600
return false;
5960259601
SDValue NotOp = V->getOperand(0);
5960359602
return peekThroughBitcasts(NotOp).getOpcode() == ISD::CONCAT_VECTORS;
5960459603
};
59605-
if (isConcatenatedNot(InVecBC.getOperand(0)) ||
59606-
isConcatenatedNot(InVecBC.getOperand(1))) {
59604+
if (isConcatenatedNot(InVec.getOperand(0)) ||
59605+
isConcatenatedNot(InVec.getOperand(1))) {
5960759606
// extract (and v4i64 X, (not (concat Y1, Y2))), n -> andnp v2i64 X(n), Y1
59608-
SDValue Concat = splitVectorIntBinary(InVecBC, DAG, SDLoc(InVecBC));
5960959607
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT,
59610-
DAG.getBitcast(InVecVT, Concat), N->getOperand(1));
59608+
splitVectorIntBinary(InVec, DAG, DL),
59609+
N->getOperand(1));
5961159610
}
5961259611
}
5961359612

@@ -59691,7 +59690,7 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5969159690
SmallVector<SDValue, 2> ShuffleInputs;
5969259691
unsigned NumSubVecs = InSizeInBits / SizeInBits;
5969359692
// Decode the shuffle mask and scale it so its shuffling subvectors.
59694-
if (getTargetShuffleInputs(InVecBC, ShuffleInputs, ShuffleMask, DAG) &&
59693+
if (getTargetShuffleInputs(InVec, ShuffleInputs, ShuffleMask, DAG) &&
5969559694
scaleShuffleElements(ShuffleMask, NumSubVecs, ScaledMask)) {
5969659695
unsigned SubVecIdx = IdxVal / NumSubElts;
5969759696
if (ScaledMask[SubVecIdx] == SM_SentinelUndef)

0 commit comments

Comments
 (0)