[X86][SSE] combineExtractWithShuffle - pull out repeated extract index code. NFCI.

This commit is contained in:
Simon Pilgrim 2020-01-22 12:08:41 +00:00
parent 201c646b2b
commit 963f268186
1 changed files with 6 additions and 3 deletions

View File

@ -37098,6 +37098,10 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
if (SrcSVT == MVT::i1 || !isa<ConstantSDNode>(Idx)) if (SrcSVT == MVT::i1 || !isa<ConstantSDNode>(Idx))
return SDValue(); return SDValue();
const APInt &IdxC = N->getConstantOperandAPInt(1);
if (IdxC.uge(NumSrcElts))
return SDValue();
SDValue SrcBC = peekThroughBitcasts(Src); SDValue SrcBC = peekThroughBitcasts(Src);
// Handle extract(broadcast(scalar_value)), it doesn't matter what index is. // Handle extract(broadcast(scalar_value)), it doesn't matter what index is.
@ -37127,8 +37131,7 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
// Handle extract(truncate(x)) for 0'th index. // Handle extract(truncate(x)) for 0'th index.
// TODO: Treat this as a faux shuffle? // TODO: Treat this as a faux shuffle?
// TODO: When can we use this for general indices? // TODO: When can we use this for general indices?
if (ISD::TRUNCATE == Src.getOpcode() && SrcVT.is128BitVector() && if (ISD::TRUNCATE == Src.getOpcode() && SrcVT.is128BitVector() && IdxC == 0) {
isNullConstant(Idx)) {
Src = extract128BitVector(Src.getOperand(0), 0, DAG, dl); Src = extract128BitVector(Src.getOperand(0), 0, DAG, dl);
Src = DAG.getBitcast(SrcVT, Src); Src = DAG.getBitcast(SrcVT, Src);
return DAG.getNode(N->getOpcode(), dl, VT, Src, Idx); return DAG.getNode(N->getOpcode(), dl, VT, Src, Idx);
@ -37170,7 +37173,7 @@ static SDValue combineExtractWithShuffle(SDNode *N, SelectionDAG &DAG,
if (Mask.size() != NumSrcElts) if (Mask.size() != NumSrcElts)
return SDValue(); return SDValue();
int SrcIdx = Mask[N->getConstantOperandVal(1)]; int SrcIdx = Mask[IdxC.getZExtValue()];
// If the shuffle source element is undef/zero then we can just accept it. // If the shuffle source element is undef/zero then we can just accept it.
if (SrcIdx == SM_SentinelUndef) if (SrcIdx == SM_SentinelUndef)