diff options
author | Artur Pilipenko <apilipenko@azulsystems.com> | 2017-02-16 12:53:26 +0000 |
---|---|---|
committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2017-02-16 12:53:26 +0000 |
commit | daaa0c0f7d405b4ebd515dc50aa0d0ebe4ee75ff (patch) | |
tree | cccd7a6d652708373f0cc122f112dd47d43f8865 /llvm/lib/CodeGen | |
parent | b376bee642344dbcc9e946b3daac05245e87ab5e (diff) | |
download | bcm5719-llvm-daaa0c0f7d405b4ebd515dc50aa0d0ebe4ee75ff.tar.gz bcm5719-llvm-daaa0c0f7d405b4ebd515dc50aa0d0ebe4ee75ff.zip |
[DAGCombiner] Support {a|s}ext, {a|z|s}ext load nodes in load combine
Support {a|s}ext, {a|z|s}ext load nodes as a part of load combine patters.
Reviewed By: filcab
Differential Revision: https://reviews.llvm.org/D29591
llvm-svn: 295314
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index cb356c63c9b..25a6431ea75 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4446,6 +4446,8 @@ const Optional<ByteProvider> calculateByteProvider(SDValue Op, unsigned Index, : calculateByteProvider(Op->getOperand(0), Index - ByteShift, Depth + 1); } + case ISD::ANY_EXTEND: + case ISD::SIGN_EXTEND: case ISD::ZERO_EXTEND: { SDValue NarrowOp = Op->getOperand(0); unsigned NarrowBitWidth = NarrowOp.getScalarValueSizeInBits(); @@ -4453,22 +4455,32 @@ const Optional<ByteProvider> calculateByteProvider(SDValue Op, unsigned Index, return None; uint64_t NarrowByteWidth = NarrowBitWidth / 8; - return Index >= NarrowByteWidth - ? ByteProvider::getConstantZero() - : calculateByteProvider(NarrowOp, Index, Depth + 1); + if (Index >= NarrowByteWidth) + return Op.getOpcode() == ISD::ZERO_EXTEND + ? Optional<ByteProvider>(ByteProvider::getConstantZero()) + : None; + else + return calculateByteProvider(NarrowOp, Index, Depth + 1); } case ISD::BSWAP: return calculateByteProvider(Op->getOperand(0), ByteWidth - Index - 1, Depth + 1); case ISD::LOAD: { auto L = cast<LoadSDNode>(Op.getNode()); + if (L->isVolatile() || L->isIndexed()) + return None; - // TODO: support ext loads - if (L->isVolatile() || L->isIndexed() || - L->getExtensionType() != ISD::NON_EXTLOAD) + unsigned NarrowBitWidth = L->getMemoryVT().getSizeInBits(); + if (NarrowBitWidth % 8 != 0) return None; + uint64_t NarrowByteWidth = NarrowBitWidth / 8; - return ByteProvider::getMemory(L, Index); + if (Index >= NarrowByteWidth) + return L->getExtensionType() == ISD::ZEXTLOAD + ? Optional<ByteProvider>(ByteProvider::getConstantZero()) + : None; + else + return ByteProvider::getMemory(L, Index); } } @@ -4548,7 +4560,6 @@ SDValue DAGCombiner::MatchLoadCombine(SDNode *N) { LoadSDNode *L = P->Load; assert(L->hasNUsesOfValue(1, 0) && !L->isVolatile() && !L->isIndexed() && - (L->getExtensionType() == ISD::NON_EXTLOAD) && "Must be enforced by calculateByteProvider"); assert(L->getOffset().isUndef() && "Unindexed load must have undef offset"); |