llvm.org GIT mirror llvm / 00edf39
Fix a bug in the DAGCombiner's handling of multiple linked MERGE_VALUES nodes. Replacing the result values with the operands in one MERGE_VALUES node may cause another MERGE_VALUES node be CSE'd with the first one, and bring its uses along, so that the first one isn't dead, as this code expects. Fix this by iterating until the node is really dead. This fixes PR4699. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78619 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
2 changed file(s) with 32 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
923923 /// MERGE_VALUES can always be eliminated.
924924 SDValue DAGCombiner::visitMERGE_VALUES(SDNode *N) {
925925 WorkListRemover DeadNodes(*this);
926 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
927 DAG.ReplaceAllUsesOfValueWith(SDValue(N, i), N->getOperand(i),
928 &DeadNodes);
926 // Replacing results may cause a different MERGE_VALUES to suddenly
927 // be CSE'd with N, and carry its uses with it. Iterate until no
928 // uses remain, to ensure that the node can be safely deleted.
929 do {
930 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
931 DAG.ReplaceAllUsesOfValueWith(SDValue(N, i), N->getOperand(i),
932 &DeadNodes);
933 } while (!N->use_empty());
929934 removeFromWorkList(N);
930935 DAG.DeleteNode(N);
931936 return SDValue(N, 0); // Return N so it doesn't get rechecked!
0 ; RUN: llvm-as < %s | llc -march=x86 >/dev/null
1 ; PR4699
2
3 ; Handle this extractvalue-of-extractvalue case without getting in
4 ; trouble with CSE in DAGCombine.
5
6 %cc = type { %crd }
7 %cr = type { i32 }
8 %crd = type { i64, %cr* }
9 %pp = type { %cc }
10
11 define fastcc void @foo(%pp* nocapture byval %p_arg) {
12 entry:
13 %tmp2 = getelementptr %pp* %p_arg, i64 0, i32 0 ; <%cc*> [#uses=
14 %tmp3 = load %cc* %tmp2 ; <%cc> [#uses=1]
15 %tmp34 = extractvalue %cc %tmp3, 0 ; <%crd> [#uses=1]
16 %tmp345 = extractvalue %crd %tmp34, 0 ; [#uses=1]
17 %.ptr.i = load %cr** undef ; <%cr*> [#uses=0]
18 %tmp15.i = shl i64 %tmp345, 3 ; [#uses=0]
19 store %cr* undef, %cr** undef
20 ret void
21 }
22
23