diff options
author | Nirav Dave <niravd@google.com> | 2019-02-20 21:07:50 +0000 |
---|---|---|
committer | Nirav Dave <niravd@google.com> | 2019-02-20 21:07:50 +0000 |
commit | 48cf37b55cc956df03c61bc41eb54fc4f582fef6 (patch) | |
tree | a3b130cba35b36ea12b86d58f77e963815928387 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 32d5b252b928105216a9b9fac7862fc1268de977 (diff) | |
download | bcm5719-llvm-48cf37b55cc956df03c61bc41eb54fc4f582fef6.tar.gz bcm5719-llvm-48cf37b55cc956df03c61bc41eb54fc4f582fef6.zip |
[DAGCombine] Generalize Dead Store to overlapping stores.
Summary:
Remove stores that are immediately overwritten by larger
stores.
Reviewers: courbet, rnk
Reviewed By: rnk
Subscribers: javed.absar, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58467
llvm-svn: 354518
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 993ab4ae551..e46cda729f3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15414,25 +15414,28 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain)) { if (ST->isUnindexed() && !ST->isVolatile() && ST1->isUnindexed() && - !ST1->isVolatile() && ST1->getBasePtr() == Ptr && - ST->getMemoryVT() == ST1->getMemoryVT()) { - // If this is a store followed by a store with the same value to the same - // location, then the store is dead/noop. - if (ST1->getValue() == Value) { - // The store is dead, remove it. + !ST1->isVolatile()) { + if (ST1->getBasePtr() == Ptr && ST1->getValue() == Value && + ST->getMemoryVT() == ST1->getMemoryVT()) { + // If this is a store followed by a store with the same value to the + // same location, then the store is dead/noop. return Chain; } - // If this is a store who's preceeding store to the same location - // and no one other node is chained to that store we can effectively - // drop the store. Do not remove stores to undef as they may be used as - // data sinks. if (OptLevel != CodeGenOpt::None && ST1->hasOneUse() && !ST1->getBasePtr().isUndef()) { - // ST1 is fully overwritten and can be elided. Combine with it's chain - // value. - CombineTo(ST1, ST1->getChain()); - return SDValue(); + const BaseIndexOffset STBase = BaseIndexOffset::match(ST, DAG); + const BaseIndexOffset ChainBase = BaseIndexOffset::match(ST1, DAG); + unsigned STByteSize = ST->getMemoryVT().getSizeInBits() / 8; + unsigned ChainByteSize = ST1->getMemoryVT().getSizeInBits() / 8; + // If this is a store who's preceeding store to a subset of the current + // location and no one other node is chained to that store we can + // effectively drop the store. Do not remove stores to undef as they may + // be used as data sinks. + if (STBase.contains(STByteSize, ChainBase, ChainByteSize, DAG)) { + CombineTo(ST1, ST1->getChain()); + return SDValue(); + } } } } |