[llvm] r358187 - [DAGCombiner] refactor narrowing of extracted vector binop; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 08:59:47 PDT 2019
Author: spatel
Date: Thu Apr 11 08:59:47 2019
New Revision: 358187
URL: http://llvm.org/viewvc/llvm-project?rev=358187&view=rev
Log:
[DAGCombiner] refactor narrowing of extracted vector binop; NFC
There's a TODO comment about handling patterns with insert_subvector,
and we do want to match that.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=358187&r1=358186&r2=358187&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Apr 11 08:59:47 2019
@@ -17425,28 +17425,27 @@ static SDValue narrowExtractedVectorBinO
LHS.getOpcode() == ISD::CONCAT_VECTORS && LHS.getNumOperands() == 2;
bool ConcatR =
RHS.getOpcode() == ISD::CONCAT_VECTORS && RHS.getNumOperands() == 2;
- if (!ConcatL && !ConcatR)
- return SDValue();
+ if (ConcatL || ConcatR) {
+ // If a binop operand was not the result of a concat, we must extract a
+ // half-sized operand for our new narrow binop:
+ // extract (binop (concat X1, X2), (concat Y1, Y2)), N --> binop XN, YN
+ // extract (binop (concat X1, X2), Y), N --> binop XN, (extract Y, IndexC)
+ // extract (binop X, (concat Y1, Y2)), N --> binop (extract X, IndexC), YN
+ SDLoc DL(Extract);
+ SDValue IndexC = DAG.getConstant(ExtBOIdx, DL, ExtBOIdxVT);
+ SDValue X = ConcatL ? DAG.getBitcast(NarrowBVT, LHS.getOperand(ConcatOpNum))
+ : DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowBVT,
+ BinOp.getOperand(0), IndexC);
- // If one of the binop operands was not the result of a concat, we must
- // extract a half-sized operand for our new narrow binop.
- SDLoc DL(Extract);
+ SDValue Y = ConcatR ? DAG.getBitcast(NarrowBVT, RHS.getOperand(ConcatOpNum))
+ : DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowBVT,
+ BinOp.getOperand(1), IndexC);
- // extract (binop (concat X1, X2), (concat Y1, Y2)), N --> binop XN, YN
- // extract (binop (concat X1, X2), Y), N --> binop XN, (extract Y, N)
- // extract (binop X, (concat Y1, Y2)), N --> binop (extract X, N), YN
- SDValue X = ConcatL ? DAG.getBitcast(NarrowBVT, LHS.getOperand(ConcatOpNum))
- : DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowBVT,
- BinOp.getOperand(0),
- DAG.getConstant(ExtBOIdx, DL, ExtBOIdxVT));
+ SDValue NarrowBinOp = DAG.getNode(BOpcode, DL, NarrowBVT, X, Y);
+ return DAG.getBitcast(VT, NarrowBinOp);
+ }
- SDValue Y = ConcatR ? DAG.getBitcast(NarrowBVT, RHS.getOperand(ConcatOpNum))
- : DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowBVT,
- BinOp.getOperand(1),
- DAG.getConstant(ExtBOIdx, DL, ExtBOIdxVT));
-
- SDValue NarrowBinOp = DAG.getNode(BOpcode, DL, NarrowBVT, X, Y);
- return DAG.getBitcast(VT, NarrowBinOp);
+ return SDValue();
}
/// If we are extracting a subvector from a wide vector load, convert to a
More information about the llvm-commits
mailing list