summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-21 14:46:21 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-21 14:46:21 +0000
commitca9933c22d1c67100468243f1e637b07d7865d71 (patch)
treed9015b2a0691cb77a00b67beb164b5117427a087 /llvm/lib/CodeGen
parentf044ebeb8d06fda55eeebb63b27eae0336c7c70c (diff)
downloadbcm5719-llvm-ca9933c22d1c67100468243f1e637b07d7865d71.tar.gz
bcm5719-llvm-ca9933c22d1c67100468243f1e637b07d7865d71.zip
[DAGCombine] narrowInsertExtractVectorBinOp - reuse "extract from insert" detection code.
Move the "extract from insert detection code" into a lambda helper function. llvm-svn: 364059
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 9c67c3e948c..4f4f502442d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -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
OpenPOWER on IntegriCloud