Skip to content

Commit 539febf

Browse files
committed
[X86] combineEXTRACT_SUBVECTOR - share the same SDLoc argument instead of recreating it over and over again.
1 parent 135529a commit 539febf

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55546,7 +55546,8 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5554655546
/// legal, but there is almost no integer math/logic available for 256-bit.
5554755547
/// This function should only be called with legal types (otherwise, the calls
5554855548
/// to get simple value types will assert).
55549-
static SDValue narrowExtractedVectorSelect(SDNode *Ext, SelectionDAG &DAG) {
55549+
static SDValue narrowExtractedVectorSelect(SDNode *Ext, const SDLoc &DL,
55550+
SelectionDAG &DAG) {
5555055551
SDValue Sel = Ext->getOperand(0);
5555155552
if (Sel.getOpcode() != ISD::VSELECT ||
5555255553
!isFreeToSplitVector(Sel.getOperand(0).getNode(), DAG))
@@ -55589,7 +55590,6 @@ static SDValue narrowExtractedVectorSelect(SDNode *Ext, SelectionDAG &DAG) {
5558955590
unsigned NarrowingFactor = WideVT.getSizeInBits() / VT.getSizeInBits();
5559055591
unsigned NarrowElts = SelElts / NarrowingFactor;
5559155592
MVT NarrowSelVT = MVT::getVectorVT(SelVT.getVectorElementType(), NarrowElts);
55592-
SDLoc DL(Ext);
5559355593
SDValue ExtCond = extract128BitVector(Sel.getOperand(0), ExtIdx, DAG, DL);
5559455594
SDValue ExtT = extract128BitVector(Sel.getOperand(1), ExtIdx, DAG, DL);
5559555595
SDValue ExtF = extract128BitVector(Sel.getOperand(2), ExtIdx, DAG, DL);
@@ -55622,6 +55622,7 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5562255622
unsigned InSizeInBits = InVecVT.getSizeInBits();
5562355623
unsigned NumSubElts = VT.getVectorNumElements();
5562455624
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
55625+
SDLoc DL(N);
5562555626

5562655627
if (Subtarget.hasAVX() && !Subtarget.hasAVX2() &&
5562755628
TLI.isTypeLegal(InVecVT) &&
@@ -55637,29 +55638,28 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5563755638
isConcatenatedNot(InVecBC.getOperand(1))) {
5563855639
// extract (and v4i64 X, (not (concat Y1, Y2))), n -> andnp v2i64 X(n), Y1
5563955640
SDValue Concat = splitVectorIntBinary(InVecBC, DAG);
55640-
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N), VT,
55641+
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT,
5564155642
DAG.getBitcast(InVecVT, Concat), N->getOperand(1));
5564255643
}
5564355644
}
5564455645

5564555646
if (DCI.isBeforeLegalizeOps())
5564655647
return SDValue();
5564755648

55648-
if (SDValue V = narrowExtractedVectorSelect(N, DAG))
55649+
if (SDValue V = narrowExtractedVectorSelect(N, DL, DAG))
5564955650
return V;
5565055651

5565155652
if (ISD::isBuildVectorAllZeros(InVec.getNode()))
55652-
return getZeroVector(VT, Subtarget, DAG, SDLoc(N));
55653+
return getZeroVector(VT, Subtarget, DAG, DL);
5565355654

5565455655
if (ISD::isBuildVectorAllOnes(InVec.getNode())) {
5565555656
if (VT.getScalarType() == MVT::i1)
55656-
return DAG.getConstant(1, SDLoc(N), VT);
55657-
return getOnesVector(VT, DAG, SDLoc(N));
55657+
return DAG.getConstant(1, DL, VT);
55658+
return getOnesVector(VT, DAG, DL);
5565855659
}
5565955660

5566055661
if (InVec.getOpcode() == ISD::BUILD_VECTOR)
55661-
return DAG.getBuildVector(VT, SDLoc(N),
55662-
InVec->ops().slice(IdxVal, NumSubElts));
55662+
return DAG.getBuildVector(VT, DL, InVec->ops().slice(IdxVal, NumSubElts));
5566355663

5566455664
// If we are extracting from an insert into a larger vector, replace with a
5566555665
// smaller insert if we don't access less than the original subvector. Don't
@@ -55669,7 +55669,6 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5566955669
InVec.getOpcode() == ISD::INSERT_SUBVECTOR && InVec.hasOneUse() &&
5567055670
IdxVal == InVec.getConstantOperandVal(2) &&
5567155671
InVec.getOperand(1).getValueSizeInBits() <= SizeInBits) {
55672-
SDLoc DL(N);
5567355672
SDValue NewExt = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT,
5567455673
InVec.getOperand(0), N->getOperand(1));
5567555674
unsigned NewIdxVal = InVec.getConstantOperandVal(2) - IdxVal;
@@ -55684,12 +55683,12 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5568455683
if (IdxVal != 0 && (InVec.getOpcode() == X86ISD::VBROADCAST ||
5568555684
InVec.getOpcode() == X86ISD::VBROADCAST_LOAD ||
5568655685
DAG.isSplatValue(InVec, /*AllowUndefs*/ false)))
55687-
return extractSubVector(InVec, 0, DAG, SDLoc(N), SizeInBits);
55686+
return extractSubVector(InVec, 0, DAG, DL, SizeInBits);
5568855687

5568955688
// If we're extracting a broadcasted subvector, just use the lowest subvector.
5569055689
if (IdxVal != 0 && InVec.getOpcode() == X86ISD::SUBV_BROADCAST_LOAD &&
5569155690
cast<MemIntrinsicSDNode>(InVec)->getMemoryVT() == VT)
55692-
return extractSubVector(InVec, 0, DAG, SDLoc(N), SizeInBits);
55691+
return extractSubVector(InVec, 0, DAG, DL, SizeInBits);
5569355692

5569455693
// Attempt to extract from the source of a shuffle vector.
5569555694
if ((InSizeInBits % SizeInBits) == 0 && (IdxVal % NumSubElts) == 0) {
@@ -55704,13 +55703,13 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5570455703
if (ScaledMask[SubVecIdx] == SM_SentinelUndef)
5570555704
return DAG.getUNDEF(VT);
5570655705
if (ScaledMask[SubVecIdx] == SM_SentinelZero)
55707-
return getZeroVector(VT, Subtarget, DAG, SDLoc(N));
55706+
return getZeroVector(VT, Subtarget, DAG, DL);
5570855707
SDValue Src = ShuffleInputs[ScaledMask[SubVecIdx] / NumSubVecs];
5570955708
if (Src.getValueSizeInBits() == InSizeInBits) {
5571055709
unsigned SrcSubVecIdx = ScaledMask[SubVecIdx] % NumSubVecs;
5571155710
unsigned SrcEltIdx = SrcSubVecIdx * NumSubElts;
5571255711
return extractSubVector(DAG.getBitcast(InVecVT, Src), SrcEltIdx, DAG,
55713-
SDLoc(N), SizeInBits);
55712+
DL, SizeInBits);
5571455713
}
5571555714
}
5571655715
}
@@ -55723,24 +55722,23 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5572355722
// v2f64 CVTDQ2PD(v4i32).
5572455723
if (InOpcode == ISD::SINT_TO_FP &&
5572555724
InVec.getOperand(0).getValueType() == MVT::v4i32) {
55726-
return DAG.getNode(X86ISD::CVTSI2P, SDLoc(N), VT, InVec.getOperand(0));
55725+
return DAG.getNode(X86ISD::CVTSI2P, DL, VT, InVec.getOperand(0));
5572755726
}
5572855727
// v2f64 CVTUDQ2PD(v4i32).
5572955728
if (InOpcode == ISD::UINT_TO_FP && Subtarget.hasVLX() &&
5573055729
InVec.getOperand(0).getValueType() == MVT::v4i32) {
55731-
return DAG.getNode(X86ISD::CVTUI2P, SDLoc(N), VT, InVec.getOperand(0));
55730+
return DAG.getNode(X86ISD::CVTUI2P, DL, VT, InVec.getOperand(0));
5573255731
}
5573355732
// v2f64 CVTPS2PD(v4f32).
5573455733
if (InOpcode == ISD::FP_EXTEND &&
5573555734
InVec.getOperand(0).getValueType() == MVT::v4f32) {
55736-
return DAG.getNode(X86ISD::VFPEXT, SDLoc(N), VT, InVec.getOperand(0));
55735+
return DAG.getNode(X86ISD::VFPEXT, DL, VT, InVec.getOperand(0));
5573755736
}
5573855737
}
5573955738
if (IdxVal == 0 &&
5574055739
(ISD::isExtOpcode(InOpcode) || ISD::isExtVecInRegOpcode(InOpcode)) &&
5574155740
(SizeInBits == 128 || SizeInBits == 256) &&
5574255741
InVec.getOperand(0).getValueSizeInBits() >= SizeInBits) {
55743-
SDLoc DL(N);
5574455742
SDValue Ext = InVec.getOperand(0);
5574555743
if (Ext.getValueSizeInBits() > SizeInBits)
5574655744
Ext = extractSubVector(Ext, 0, DAG, DL, SizeInBits);
@@ -55751,23 +55749,20 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5575155749
InVec.getOperand(0).getValueType().is256BitVector() &&
5575255750
InVec.getOperand(1).getValueType().is256BitVector() &&
5575355751
InVec.getOperand(2).getValueType().is256BitVector()) {
55754-
SDLoc DL(N);
5575555752
SDValue Ext0 = extractSubVector(InVec.getOperand(0), 0, DAG, DL, 128);
5575655753
SDValue Ext1 = extractSubVector(InVec.getOperand(1), 0, DAG, DL, 128);
5575755754
SDValue Ext2 = extractSubVector(InVec.getOperand(2), 0, DAG, DL, 128);
5575855755
return DAG.getNode(InOpcode, DL, VT, Ext0, Ext1, Ext2);
5575955756
}
5576055757
if (IdxVal == 0 && InOpcode == ISD::TRUNCATE && Subtarget.hasVLX() &&
5576155758
(VT.is128BitVector() || VT.is256BitVector())) {
55762-
SDLoc DL(N);
5576355759
SDValue InVecSrc = InVec.getOperand(0);
5576455760
unsigned Scale = InVecSrc.getValueSizeInBits() / InSizeInBits;
5576555761
SDValue Ext = extractSubVector(InVecSrc, 0, DAG, DL, Scale * SizeInBits);
5576655762
return DAG.getNode(InOpcode, DL, VT, Ext);
5576755763
}
5576855764
if (InOpcode == X86ISD::MOVDDUP &&
5576955765
(VT.is128BitVector() || VT.is256BitVector())) {
55770-
SDLoc DL(N);
5577155766
SDValue Ext0 =
5577255767
extractSubVector(InVec.getOperand(0), IdxVal, DAG, DL, SizeInBits);
5577355768
return DAG.getNode(InOpcode, DL, VT, Ext0);
@@ -55779,7 +55774,6 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5577955774
if ((InOpcode == X86ISD::VSHLI || InOpcode == X86ISD::VSRLI) &&
5578055775
InVecVT.getScalarSizeInBits() == 64 &&
5578155776
InVec.getConstantOperandAPInt(1) == 32) {
55782-
SDLoc DL(N);
5578355777
SDValue Ext =
5578455778
extractSubVector(InVec.getOperand(0), IdxVal, DAG, DL, SizeInBits);
5578555779
return DAG.getNode(InOpcode, DL, VT, Ext, InVec.getOperand(1));

0 commit comments

Comments
 (0)