forked from OSchip/llvm-project
X86ISelLowering.cpp - remove non-constant EXTRACT_SUBVECTOR/INSERT_SUBVECTOR handling. NFC.
Now that D79814 has landed, we can assume that subvector ops use constant, in-range indices.
This commit is contained in:
parent
36b9b1e617
commit
1024e82469
|
@ -5786,8 +5786,7 @@ static bool collectConcatOps(SDNode *N, SmallVectorImpl<SDValue> &Ops) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (N->getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(N->getOperand(2))) {
|
||||
if (N->getOpcode() == ISD::INSERT_SUBVECTOR) {
|
||||
SDValue Src = N->getOperand(0);
|
||||
SDValue Sub = N->getOperand(1);
|
||||
const APInt &Idx = N->getConstantOperandAPInt(2);
|
||||
|
@ -5939,21 +5938,17 @@ static SDValue insert1BitVector(SDValue Op, SelectionDAG &DAG,
|
|||
SDValue Vec = Op.getOperand(0);
|
||||
SDValue SubVec = Op.getOperand(1);
|
||||
SDValue Idx = Op.getOperand(2);
|
||||
|
||||
if (!isa<ConstantSDNode>(Idx))
|
||||
return SDValue();
|
||||
unsigned IdxVal = Op.getConstantOperandVal(2);
|
||||
|
||||
// Inserting undef is a nop. We can just return the original vector.
|
||||
if (SubVec.isUndef())
|
||||
return Vec;
|
||||
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
if (IdxVal == 0 && Vec.isUndef()) // the operation is legal
|
||||
return Op;
|
||||
|
||||
MVT OpVT = Op.getSimpleValueType();
|
||||
unsigned NumElems = OpVT.getVectorNumElements();
|
||||
|
||||
SDValue ZeroIdx = DAG.getIntPtrConstant(0, dl);
|
||||
|
||||
// Extend to natively supported kshift.
|
||||
|
@ -5973,7 +5968,6 @@ static SDValue insert1BitVector(SDValue Op, SelectionDAG &DAG,
|
|||
|
||||
MVT SubVecVT = SubVec.getSimpleValueType();
|
||||
unsigned SubVecNumElems = SubVecVT.getVectorNumElements();
|
||||
|
||||
assert(IdxVal + SubVecNumElems <= NumElems &&
|
||||
IdxVal % SubVecVT.getSizeInBits() == 0 &&
|
||||
"Unexpected index value in INSERT_SUBVECTOR");
|
||||
|
@ -6528,8 +6522,7 @@ static bool getTargetConstantBitsFromNode(SDValue Op, unsigned EltSizeInBits,
|
|||
}
|
||||
|
||||
// Insert constant bits from a base and sub vector sources.
|
||||
if (Op.getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(Op.getOperand(2))) {
|
||||
if (Op.getOpcode() == ISD::INSERT_SUBVECTOR) {
|
||||
// TODO - support insert_subvector through bitcasts.
|
||||
if (EltSizeInBits != VT.getScalarSizeInBits())
|
||||
return false;
|
||||
|
@ -6551,8 +6544,7 @@ static bool getTargetConstantBitsFromNode(SDValue Op, unsigned EltSizeInBits,
|
|||
}
|
||||
|
||||
// Extract constant bits from a subvector's source.
|
||||
if (Op.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(Op.getOperand(1))) {
|
||||
if (Op.getOpcode() == ISD::EXTRACT_SUBVECTOR) {
|
||||
// TODO - support extract_subvector through bitcasts.
|
||||
if (EltSizeInBits != VT.getScalarSizeInBits())
|
||||
return false;
|
||||
|
@ -7227,15 +7219,11 @@ static bool getTargetShuffleAndZeroables(SDValue N, SmallVectorImpl<int> &Mask,
|
|||
SDValue Vec = V.getOperand(0);
|
||||
int NumVecElts = Vec.getValueType().getVectorNumElements();
|
||||
if (Vec.isUndef() && Size == NumVecElts) {
|
||||
auto *CIdx = dyn_cast<ConstantSDNode>(V.getOperand(2));
|
||||
int Idx = V.getConstantOperandVal(2);
|
||||
int NumSubElts = V.getOperand(1).getValueType().getVectorNumElements();
|
||||
if (CIdx && CIdx->getAPIntValue().ule(NumVecElts - NumSubElts)) {
|
||||
int Idx = CIdx->getZExtValue();
|
||||
if (M < Idx || (Idx + NumSubElts) <= M) {
|
||||
if (M < Idx || (Idx + NumSubElts) <= M)
|
||||
KnownUndef.setBit(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -7435,14 +7423,12 @@ static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
|
|||
SDValue Sub = N.getOperand(1);
|
||||
EVT SubVT = Sub.getValueType();
|
||||
unsigned NumSubElts = SubVT.getVectorNumElements();
|
||||
if (!isa<ConstantSDNode>(N.getOperand(2)) ||
|
||||
!N->isOnlyUserOf(Sub.getNode()))
|
||||
if (!N->isOnlyUserOf(Sub.getNode()))
|
||||
return false;
|
||||
uint64_t InsertIdx = N.getConstantOperandVal(2);
|
||||
// Handle INSERT_SUBVECTOR(SRC0, EXTRACT_SUBVECTOR(SRC1)).
|
||||
if (Sub.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
|
||||
Sub.getOperand(0).getValueType() == VT &&
|
||||
isa<ConstantSDNode>(Sub.getOperand(1))) {
|
||||
Sub.getOperand(0).getValueType() == VT) {
|
||||
uint64_t ExtractIdx = Sub.getConstantOperandVal(1);
|
||||
for (int i = 0; i != (int)NumElts; ++i)
|
||||
Mask.push_back(i);
|
||||
|
@ -7869,13 +7855,11 @@ static SDValue getShuffleScalarElt(SDValue Op, unsigned Index,
|
|||
}
|
||||
|
||||
// Recurse into insert_subvector base/sub vector to find scalars.
|
||||
if (Opcode == ISD::INSERT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(Op.getOperand(2))) {
|
||||
if (Opcode == ISD::INSERT_SUBVECTOR) {
|
||||
SDValue Vec = Op.getOperand(0);
|
||||
SDValue Sub = Op.getOperand(1);
|
||||
EVT SubVT = Sub.getValueType();
|
||||
unsigned NumSubElts = SubVT.getVectorNumElements();
|
||||
uint64_t SubIdx = Op.getConstantOperandVal(2);
|
||||
unsigned NumSubElts = Sub.getValueType().getVectorNumElements();
|
||||
|
||||
if (SubIdx <= Index && Index < (SubIdx + NumSubElts))
|
||||
return getShuffleScalarElt(Sub, Index - SubIdx, DAG, Depth + 1);
|
||||
|
@ -7892,8 +7876,7 @@ static SDValue getShuffleScalarElt(SDValue Op, unsigned Index,
|
|||
}
|
||||
|
||||
// Recurse into extract_subvector src vector to find scalars.
|
||||
if (Opcode == ISD::EXTRACT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(Op.getOperand(1))) {
|
||||
if (Opcode == ISD::EXTRACT_SUBVECTOR) {
|
||||
SDValue Src = Op.getOperand(0);
|
||||
uint64_t SrcIdx = Op.getConstantOperandVal(1);
|
||||
return getShuffleScalarElt(Src, Index + SrcIdx, DAG, Depth + 1);
|
||||
|
@ -13175,8 +13158,7 @@ static SDValue lowerShuffleOfExtractsAsVperm(const SDLoc &DL, SDValue N0,
|
|||
|
||||
SDValue WideVec = N0.getOperand(0);
|
||||
MVT WideVT = WideVec.getSimpleValueType();
|
||||
if (!WideVT.is256BitVector() || !isa<ConstantSDNode>(N0.getOperand(1)) ||
|
||||
!isa<ConstantSDNode>(N1.getOperand(1)))
|
||||
if (!WideVT.is256BitVector())
|
||||
return SDValue();
|
||||
|
||||
// Match extracts of each half of the wide source vector. Commute the shuffle
|
||||
|
@ -13258,13 +13240,9 @@ static SDValue lowerShuffleAsBroadcast(const SDLoc &DL, MVT VT, SDValue V1,
|
|||
continue;
|
||||
}
|
||||
case ISD::EXTRACT_SUBVECTOR: {
|
||||
auto *ConstantIdx = dyn_cast<ConstantSDNode>(V.getOperand(1));
|
||||
if (!ConstantIdx)
|
||||
break;
|
||||
|
||||
// The extraction index adds to the existing offset.
|
||||
unsigned EltBitWidth = V.getScalarValueSizeInBits();
|
||||
unsigned Idx = ConstantIdx->getZExtValue();
|
||||
unsigned Idx = V.getConstantOperandVal(1);
|
||||
unsigned BeginOffset = Idx * EltBitWidth;
|
||||
BitOffset += BeginOffset;
|
||||
V = V.getOperand(0);
|
||||
|
@ -13272,12 +13250,8 @@ static SDValue lowerShuffleAsBroadcast(const SDLoc &DL, MVT VT, SDValue V1,
|
|||
}
|
||||
case ISD::INSERT_SUBVECTOR: {
|
||||
SDValue VOuter = V.getOperand(0), VInner = V.getOperand(1);
|
||||
auto ConstantIdx = dyn_cast<ConstantSDNode>(V.getOperand(2));
|
||||
if (!ConstantIdx)
|
||||
break;
|
||||
|
||||
int EltBitWidth = VOuter.getScalarValueSizeInBits();
|
||||
int Idx = (int)ConstantIdx->getZExtValue();
|
||||
int Idx = (int)V.getConstantOperandVal(2);
|
||||
int NumSubElts = (int)VInner.getSimpleValueType().getVectorNumElements();
|
||||
int BeginOffset = Idx * EltBitWidth;
|
||||
int EndOffset = BeginOffset + NumSubElts * EltBitWidth;
|
||||
|
@ -18529,12 +18503,8 @@ static SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, const X86Subtarget &Subtarget,
|
|||
|
||||
SDLoc dl(Op);
|
||||
SDValue Vec = Op.getOperand(0);
|
||||
SDValue Idx = Op.getOperand(1);
|
||||
uint64_t IdxVal = Op.getConstantOperandVal(1);
|
||||
|
||||
if (!isa<ConstantSDNode>(Idx))
|
||||
return SDValue();
|
||||
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
if (IdxVal == 0) // the operation is legal
|
||||
return Op;
|
||||
|
||||
|
@ -34785,8 +34755,7 @@ static SDValue combineX86ShuffleChainWithExtract(
|
|||
unsigned &Offset = Offsets[i];
|
||||
Src = peekThroughBitcasts(Src);
|
||||
EVT BaseVT = Src.getValueType();
|
||||
while (Src.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
|
||||
isa<ConstantSDNode>(Src.getOperand(1))) {
|
||||
while (Src.getOpcode() == ISD::EXTRACT_SUBVECTOR) {
|
||||
Offset += Src.getConstantOperandVal(1);
|
||||
Src = Src.getOperand(0);
|
||||
}
|
||||
|
@ -35886,9 +35855,7 @@ static SDValue combineTargetShuffle(SDValue N, SelectionDAG &DAG,
|
|||
if (!(Imm == 0x31 &&
|
||||
Ins0.getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
Ins1.getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
Ins0.getValueType() == Ins1.getValueType() &&
|
||||
isa<ConstantSDNode>(Ins0.getOperand(2)) &&
|
||||
isa<ConstantSDNode>(Ins1.getOperand(2))))
|
||||
Ins0.getValueType() == Ins1.getValueType()))
|
||||
return SDValue();
|
||||
|
||||
SDValue X = Ins0.getOperand(1);
|
||||
|
@ -47148,7 +47115,7 @@ static SDValue narrowExtractedVectorSelect(SDNode *Ext, SelectionDAG &DAG) {
|
|||
|
||||
unsigned SelElts = SelVT.getVectorNumElements();
|
||||
unsigned CastedElts = WideVT.getVectorNumElements();
|
||||
unsigned ExtIdx = cast<ConstantSDNode>(Ext->getOperand(1))->getZExtValue();
|
||||
unsigned ExtIdx = Ext->getConstantOperandVal(1);
|
||||
if (SelElts % CastedElts == 0) {
|
||||
// The select has the same or more (narrower) elements than the extract
|
||||
// operand. The extraction index gets scaled by that factor.
|
||||
|
@ -47193,6 +47160,7 @@ static SDValue combineExtractSubvector(SDNode *N, SelectionDAG &DAG,
|
|||
|
||||
MVT VT = N->getSimpleValueType(0);
|
||||
SDValue InVec = N->getOperand(0);
|
||||
unsigned IdxVal = N->getConstantOperandVal(1);
|
||||
SDValue InVecBC = peekThroughBitcasts(InVec);
|
||||
EVT InVecVT = InVec.getValueType();
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
|
@ -47222,8 +47190,6 @@ static SDValue combineExtractSubvector(SDNode *N, SelectionDAG &DAG,
|
|||
if (SDValue V = narrowExtractedVectorSelect(N, DAG))
|
||||
return V;
|
||||
|
||||
unsigned IdxVal = cast<ConstantSDNode>(N->getOperand(1))->getZExtValue();
|
||||
|
||||
if (ISD::isBuildVectorAllZeros(InVec.getNode()))
|
||||
return getZeroVector(VT, Subtarget, DAG, SDLoc(N));
|
||||
|
||||
|
|
Loading…
Reference in New Issue