diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-18 03:05:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-18 03:05:22 +0000 |
commit | ec06e9a6707b9b00889e34ebad7cd3f20cb70bb6 (patch) | |
tree | babffbdace659951b5d1aa0729b2af1db057c5bf /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 1e6cf8630fa879c471c8623d90e3382b1344b80b (diff) |
When replacing a node in SimplifyDemandedBits, if the old node used any
single-use nodes, they will be dead soon. Make sure to remove them before
processing other nodes. This implements CodeGen/X86/shl_elim.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 19eff10f4d..20b9a588e2 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -182,6 +182,13 @@ namespace { // something else needing this node. if (TLO.Old.Val->use_empty()) { removeFromWorkList(TLO.Old.Val); + + // If the operands of this node are only used by the node, they will now + // be dead. Make sure to visit them first to delete dead nodes early. + for (unsigned i = 0, e = TLO.Old.Val->getNumOperands(); i != e; ++i) + if (TLO.Old.Val->getOperand(i).Val->hasOneUse()) + AddToWorkList(TLO.Old.Val->getOperand(i).Val); + DAG.DeleteNode(TLO.Old.Val); } return true; @@ -1838,6 +1845,7 @@ SDOperand DAGCombiner::visitSRL(SDNode *N) { // if (srl x, c) is known to be zero, return 0 if (N1C && TLI.MaskedValueIsZero(SDOperand(N, 0), ~0ULL >> (64-OpSizeInBits))) return DAG.getConstant(0, VT); + // fold (srl (srl x, c1), c2) -> 0 or (srl x, c1+c2) if (N1C && N0.getOpcode() == ISD::SRL && N0.getOperand(1).getOpcode() == ISD::Constant) { @@ -1899,7 +1907,6 @@ SDOperand DAGCombiner::visitSRL(SDNode *N) { return DAG.getNode(ISD::XOR, VT, Op, DAG.getConstant(1, VT)); } } - return SDOperand(); } |