diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-01-29 19:13:39 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-01-29 19:13:39 +0000 |
commit | a61d586f744dcfb7280f59f0204b15b8b084f26b (patch) | |
tree | 5681a0290b515ed3f4f6315d50732bdddabbcb92 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 2a5a0ad1e464d3f7de437540328bfda5ac5b5538 (diff) | |
download | bcm5719-llvm-a61d586f744dcfb7280f59f0204b15b8b084f26b.tar.gz bcm5719-llvm-a61d586f744dcfb7280f59f0204b15b8b084f26b.zip |
[DAGCombiner] fold extract_subvector of extract_subvector
This is the sibling fold for insert-of-insert that was added with D56604.
Now that we have x86 shuffle narrowing (D57156), this change shows improvements for
lots of AVX512 reduction code (not sure that we would ever expect extract-of-extract otherwise).
There's a small regression in some of the partial-permute tests (extracting followed by splat).
That is tracked by PR40500:
https://bugs.llvm.org/show_bug.cgi?id=40500
Differential Revision: https://reviews.llvm.org/D57336
llvm-svn: 352528
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 871c8ddb8f1..9837f5b4497 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -17079,6 +17079,19 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode* N) { if (SDValue NarrowLoad = narrowExtractedVectorLoad(N, DAG)) return NarrowLoad; + // Combine an extract of an extract into a single extract_subvector. + // ext (ext X, C), 0 --> ext X, C + if (isNullConstant(N->getOperand(1)) && + V.getOpcode() == ISD::EXTRACT_SUBVECTOR && V.hasOneUse() && + isa<ConstantSDNode>(V.getOperand(1))) { + if (TLI.isExtractSubvectorCheap(NVT, V.getOperand(0).getValueType(), + V.getConstantOperandVal(1)) && + TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, NVT)) { + return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N), NVT, V.getOperand(0), + V.getOperand(1)); + } + } + // Combine: // (extract_subvec (concat V1, V2, ...), i) // Into: |