summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorNirav Dave <niravd@google.com>2016-11-23 16:48:35 +0000
committerNirav Dave <niravd@google.com>2016-11-23 16:48:35 +0000
commitcf34556330f3bcf467b8c3981f09aac4d7f965e1 (patch)
tree281686e3b8a42b91f1086844c33771e3aeae2c57 /llvm/lib/CodeGen/SelectionDAG
parent5ea1054dabb414e2e8cb89c90698300dae0bf7c4 (diff)
downloadbcm5719-llvm-cf34556330f3bcf467b8c3981f09aac4d7f965e1.tar.gz
bcm5719-llvm-cf34556330f3bcf467b8c3981f09aac4d7f965e1.zip
[DAG] Improve loads-from-store forwarding to handle TokenFactor
Forward store values to matching loads down through token factors. Factored from D14834. Reviewers: jyknight, hfinkel Subscribers: hfinkel, nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D26080 llvm-svn: 287773
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b3813ba82ce..e3cab19733b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10265,11 +10265,22 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
// TODO: Handle TRUNCSTORE/LOADEXT
if (OptLevel != CodeGenOpt::None &&
ISD::isNormalLoad(N) && !LD->isVolatile()) {
- if (ISD::isNON_TRUNCStore(Chain.getNode())) {
+ // Either a direct store, or a store off of a TokenFactor can be
+ // forwarded.
+ if (Chain->getOpcode() == ISD::TokenFactor) {
+ for (const SDValue &ChainOp : Chain->op_values()) {
+ if (ISD::isNON_TRUNCStore(ChainOp.getNode())) {
+ StoreSDNode *PrevST = cast<StoreSDNode>(ChainOp);
+ if (PrevST->getBasePtr() == Ptr &&
+ PrevST->getValue().getValueType() == N->getValueType(0))
+ return CombineTo(N, PrevST->getOperand(1), Chain);
+ }
+ }
+ } else if (ISD::isNON_TRUNCStore(Chain.getNode())) {
StoreSDNode *PrevST = cast<StoreSDNode>(Chain);
if (PrevST->getBasePtr() == Ptr &&
PrevST->getValue().getValueType() == N->getValueType(0))
- return CombineTo(N, Chain.getOperand(1), Chain);
+ return CombineTo(N, PrevST->getOperand(1), Chain);
}
}
OpenPOWER on IntegriCloud