summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-16 05:49:24 +0000
committerChris Lattner <sabre@nondot.org>2008-01-16 05:49:24 +0000
commit2e50a6f90fb8aa9d2a4ffca9e0b00600bbf428a7 (patch)
treed376553ede78cd9b2f9fbe753754073c52aca44b /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent29185f17e9335dfd48181a0ae9c5a1b50ff619b5 (diff)
downloadbcm5719-llvm-2e50a6f90fb8aa9d2a4ffca9e0b00600bbf428a7.tar.gz
bcm5719-llvm-2e50a6f90fb8aa9d2a4ffca9e0b00600bbf428a7.zip
Factor the ReachesChainWithoutSideEffects out of dag combiner into
a public SDOperand::reachesChainWithoutSideEffects method. No functionality change. llvm-svn: 46050
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp29
1 files changed, 1 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 0bb11fa330b..09e0c3e0008 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4122,33 +4122,6 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
return SDOperand();
}
-/// ReachesChainWithoutSideEffects - Do a little local search to see if Src can
-/// reach Dest without any side effects like a store, or call. Non-volatile
-/// loads are ok though.
-static bool ReachesChainWithoutSideEffects(SDOperand Src, SDOperand Dest,
- unsigned Depth = 0) {
- if (Src == Dest) return true;
-
- // Don't search too deeply, we just want to be able to see through
- // TokenFactor's etc.
- if (Depth == 2) return false;
-
- // If this is a token factor, all inputs to the TF happen in parallel. If any
- // of the operands of the TF reach dest, then we can do the xform.
- if (Src.getOpcode() == ISD::TokenFactor) {
- for (unsigned i = 0, e = Src.getNumOperands(); i != e; ++i)
- if (ReachesChainWithoutSideEffects(Src.getOperand(i), Dest, Depth+1))
- return true;
- return false;
- }
-
- // Loads don't have side effects, look through them.
- if (LoadSDNode *Ld = dyn_cast<LoadSDNode>(Src)) {
- if (!Ld->isVolatile())
- return ReachesChainWithoutSideEffects(Ld->getChain(), Dest, Depth+1);
- }
- return false;
-}
SDOperand DAGCombiner::visitSTORE(SDNode *N) {
StoreSDNode *ST = cast<StoreSDNode>(N);
@@ -4283,7 +4256,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
!ST->isVolatile() &&
// There can't be any side effects between the load and store, such as
// a call or store.
- ReachesChainWithoutSideEffects(Chain, SDOperand(Ld, 1))) {
+ Chain.reachesChainWithoutSideEffects(SDOperand(Ld, 1))) {
// The store is dead, remove it.
return Chain;
}
OpenPOWER on IntegriCloud