mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-09 21:32:49 +00:00
[DAGCombine] narrowInsertExtractVectorBinOp - reuse "extract from insert" detection code.
Move the "extract from insert detection code" into a lambda helper function. llvm-svn: 364059
This commit is contained in:
parent
13188b5a1b
commit
3b26b2fac1
@ -17889,30 +17889,34 @@ static SDValue narrowInsertExtractVectorBinOp(SDNode *Extract,
|
||||
SelectionDAG &DAG) {
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
SDValue BinOp = Extract->getOperand(0);
|
||||
if (!TLI.isBinOp(BinOp.getOpcode()) || BinOp.getNode()->getNumValues() != 1)
|
||||
unsigned BinOpcode = BinOp.getOpcode();
|
||||
if (!TLI.isBinOp(BinOpcode) || BinOp.getNode()->getNumValues() != 1)
|
||||
return SDValue();
|
||||
|
||||
SDValue Bop0 = BinOp.getOperand(0), Bop1 = BinOp.getOperand(1);
|
||||
SDValue Index = Extract->getOperand(1);
|
||||
EVT VT = Extract->getValueType(0);
|
||||
bool IsInsert0 = Bop0.getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
Bop0.getOperand(1).getValueType() == VT &&
|
||||
Bop0.getOperand(2) == Index;
|
||||
bool IsInsert1 = Bop1.getOpcode() == ISD::INSERT_SUBVECTOR &&
|
||||
Bop1.getOperand(1).getValueType() == VT &&
|
||||
Bop1.getOperand(2) == Index;
|
||||
|
||||
auto GetSubVector = [VT, Index](SDValue V) {
|
||||
if (V.getOpcode() != ISD::INSERT_SUBVECTOR ||
|
||||
V.getOperand(1).getValueType() != VT || V.getOperand(2) != Index)
|
||||
return SDValue();
|
||||
return V.getOperand(1);
|
||||
};
|
||||
SDValue Sub0 = GetSubVector(Bop0);
|
||||
SDValue Sub1 = GetSubVector(Bop1);
|
||||
|
||||
// TODO: We could handle the case where only 1 operand is being inserted by
|
||||
// creating an extract of the other operand, but that requires checking
|
||||
// number of uses and/or costs.
|
||||
if (!IsInsert0 || !IsInsert1 ||
|
||||
!TLI.isOperationLegalOrCustom(BinOp.getOpcode(), VT))
|
||||
if (!Sub0 || !Sub1 || !TLI.isOperationLegalOrCustom(BinOpcode, VT))
|
||||
return SDValue();
|
||||
|
||||
// We are inserting both operands of the wide binop only to extract back
|
||||
// to the narrow vector size. Eliminate all of the insert/extract:
|
||||
// ext (binop (ins ?, X, Index), (ins ?, Y, Index)), Index --> binop X, Y
|
||||
return DAG.getNode(BinOp.getOpcode(), SDLoc(Extract), VT, Bop0.getOperand(1),
|
||||
Bop1.getOperand(1), BinOp->getFlags());
|
||||
return DAG.getNode(BinOpcode, SDLoc(Extract), VT, Sub0, Sub1,
|
||||
BinOp->getFlags());
|
||||
}
|
||||
|
||||
/// If we are extracting a subvector produced by a wide binary operator try
|
||||
|
Loading…
Reference in New Issue
Block a user