diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2020-01-09 09:36:22 -0500 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2020-01-09 09:38:12 -0500 |
| commit | cb5612e2df893728887bedd41aa2293f454c7845 (patch) | |
| tree | e44fdefb72c919dd35ad25916bdb7339dba645a2 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 84ce46269cfda8800346706251ac3587b2d1c9f5 (diff) | |
| download | bcm5719-llvm-cb5612e2df893728887bedd41aa2293f454c7845.tar.gz bcm5719-llvm-cb5612e2df893728887bedd41aa2293f454c7845.zip | |
[DAGCombiner] reduce extract subvector of concat
If we are extracting a chunk of a vector that's a fraction of an
operand of the concatenated vector operand, we can extract directly
from one of those original operands.
This is another suggestion from PR42024:
https://bugs.llvm.org/show_bug.cgi?id=42024#c2
But I'm not sure yet if it will make any difference on those patterns.
It seems to help a few existing AVX512 tests though.
Differential Revision: https://reviews.llvm.org/D72361
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 37b1b17218d..6030c957420 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -18594,8 +18594,22 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { if (ConcatSrcNumElts == ExtNumElts) return V.getOperand(ConcatOpIdx); - // TODO: Handle the case where the concat operands are larger than the - // result of this extract by extracting directly from a concat op. + // If the concatenated source vectors are a multiple length of this extract, + // then extract a fraction of one of those source vectors directly from a + // concat operand. Example: + // v2i8 extract_subvec (v16i8 concat (v8i8 X), (v8i8 Y), 14 --> + // v2i8 extract_subvec v8i8 Y, 6 + if (ConcatSrcNumElts % ExtNumElts == 0) { + SDLoc DL(N); + unsigned NewExtIdx = ExtIdx - ConcatOpIdx * ConcatSrcNumElts; + assert(NewExtIdx + ExtNumElts <= ConcatSrcNumElts && + "Trying to extract from >1 concat operand?"); + assert(NewExtIdx % ExtNumElts == 0 && + "Extract index is not a multiple of the input vector length."); + SDValue NewIndexC = DAG.getIntPtrConstant(NewExtIdx, DL); + return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NVT, + V.getOperand(ConcatOpIdx), NewIndexC); + } } V = peekThroughBitcasts(V); |

