changeset 11309:2f216d44bce4

Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 15 Aug 2013 19:42:47 +0200
parents 77167d6f868c
children 9f317a663366
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Wed Aug 14 17:02:45 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Thu Aug 15 19:42:47 2013 +0200
@@ -548,20 +548,23 @@
                 }
 
                 if (replacement != null) {
-                    NodeIterable<Node> anchored = survivingSuccessor.anchored();
-                    if (!anchored.isEmpty() && replacementAnchor == null) {
-                        // Cannot simplify an IfNode unless we have a new anchor point
-                        // for any nodes currently anchored to the surviving branch
-                    } else {
-                        if (!anchored.isEmpty()) {
-                            for (Node a : anchored.snapshot()) {
-                                a.replaceFirstInput(survivingSuccessor, replacementAnchor);
+                    for (Node n : survivingSuccessor.usages().snapshot()) {
+                        if (n instanceof GuardNode || n instanceof ProxyNode) {
+                            // Keep wired to the begin node.
+                        } else {
+                            if (replacementAnchor == null) {
+                                // Cannot simplify this IfNode as there is no anchor.
+                                return;
                             }
+
+                            // Rewire to the replacement anchor.
+                            n.replaceFirstInput(survivingSuccessor, replacementAnchor);
                         }
-                        ifNode.setCondition(replacement);
-                        if (compare.usages().isEmpty()) {
-                            GraphUtil.killWithUnusedFloatingInputs(compare);
-                        }
+                    }
+
+                    ifNode.setCondition(replacement);
+                    if (compare.usages().isEmpty()) {
+                        GraphUtil.killWithUnusedFloatingInputs(compare);
                     }
                 }
             } else if (node instanceof AbstractEndNode) {