summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-24 07:57:06 +0000
committerChris Lattner <sabre@nondot.org>2008-01-24 07:57:06 +0000
commite97fa8cdf05c02dc257ed9590ccc2e7e60c726e9 (patch)
tree32b321b3da220d162a51e1558fbadf3c41c24df5 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentd66eac62fda5f83ef7d3f2b4339873defe353327 (diff)
downloadbcm5719-llvm-e97fa8cdf05c02dc257ed9590ccc2e7e60c726e9.tar.gz
bcm5719-llvm-e97fa8cdf05c02dc257ed9590ccc2e7e60c726e9.zip
Fix this buggy transformation. Two observations:
1. we already know the value is dead, so don't bother replacing it with undef. 2. The very case the comment describes actually makes the load live which asserts in deletenode. If we do the replacement and the node becomes live, just treat it as new. This fixes a failure on X86/2008-01-16-InvalidDAGCombineXform.ll with some local changes in my tree. llvm-svn: 46306
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 788c8c04a82..6ce29fb89fb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4090,28 +4090,19 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
// v1, chain2 = load chain1, loc
// v2, chain3 = load chain2, loc
// v3 = add v2, c
- // Now we replace use of v1 with undef, use of chain2 with chain1.
- // ReplaceAllUsesWith() will iterate through uses of the first load and
- // update operands:
- // v1, chain2 = load chain1, loc
- // v2, chain3 = load chain1, loc
- // v3 = add v2, c
- // Now the second load is the same as the first load, SelectionDAG cse
- // will ensure the use of second load is replaced with the first load.
- // v1, chain2 = load chain1, loc
- // v3 = add v1, c
- // Then v1 is replaced with undef and bad things happen.
+ // Now we replace use of chain2 with chain1. This makes the second load
+ // isomorphic to the one we are deleting, and thus makes this load live.
std::vector<SDNode*> NowDead;
- SDOperand Undef = DAG.getNode(ISD::UNDEF, N->getValueType(0));
DOUT << "\nReplacing.6 "; DEBUG(N->dump(&DAG));
- DOUT << "\nWith: "; DEBUG(Undef.Val->dump(&DAG));
- DOUT << " and 1 other value\n";
- DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 0), Undef, &NowDead);
+ DOUT << "\nWith chain: "; DEBUG(Chain.Val->dump(&DAG));
+ DOUT << "\n";
DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 1), Chain, &NowDead);
- removeFromWorkList(N);
for (unsigned i = 0, e = NowDead.size(); i != e; ++i)
removeFromWorkList(NowDead[i]);
- DAG.DeleteNode(N);
+ if (N->use_empty()) {
+ removeFromWorkList(N);
+ DAG.DeleteNode(N);
+ }
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
}
} else {
OpenPOWER on IntegriCloud