# HG changeset patch # User Thomas Wuerthinger # Date 1376588567 -7200 # Node ID 2f216d44bce434a771f337426db840d9bafc609c # Parent 77167d6f868c62150c634ffdf14970b914cf389a Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode. diff -r 77167d6f868c -r 2f216d44bce4 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- 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 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) {