# HG changeset patch # User Thomas Wuerthinger # Date 1309273196 -7200 # Node ID 222f60eb09a78800837493516e67f4b6ac720114 # Parent b9307b923f26174c6b81fc98bbfa84b90be0d362 Replace If node with guard in case of deopt. diff -r b9307b923f26 -r 222f60eb09a7 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Tue Jun 28 15:54:46 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Tue Jun 28 16:59:56 2011 +0200 @@ -488,7 +488,7 @@ if (node instanceof Compare) { return emitCompare((Compare) node); } else { - throw Util.unimplemented(); + throw Util.unimplemented(node.toString()); } } diff -r b9307b923f26 -r 222f60eb09a7 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/BooleanNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/BooleanNode.java Tue Jun 28 15:54:46 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/BooleanNode.java Tue Jun 28 16:59:56 2011 +0200 @@ -32,4 +32,8 @@ super(kind, inputCount, successorCount, graph); } + + public BooleanNode negate() { + throw new IllegalStateException(); + } } diff -r b9307b923f26 -r 222f60eb09a7 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Compare.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Compare.java Tue Jun 28 15:54:46 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Compare.java Tue Jun 28 16:59:56 2011 +0200 @@ -144,4 +144,9 @@ x.unorderedIsTrue = unorderedIsTrue; return x; } + + @Override + public BooleanNode negate() { + return new Compare(x(), condition.negate(), y(), graph()); + } } diff -r b9307b923f26 -r 222f60eb09a7 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Tue Jun 28 15:54:46 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Tue Jun 28 16:59:56 2011 +0200 @@ -24,7 +24,6 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.debug.*; -import com.oracle.max.graal.compiler.ir.*; import com.oracle.max.graal.graph.*; /** diff -r b9307b923f26 -r 222f60eb09a7 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Tue Jun 28 15:54:46 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Tue Jun 28 16:59:56 2011 +0200 @@ -1124,6 +1124,36 @@ } private Value append(FixedNode fixed) { + if (fixed instanceof Deoptimize && lastInstr.predecessors().size() > 0) { + Node cur = lastInstr; + Node prev = cur; + while (cur != cur.graph().start() && !(cur instanceof ControlSplit)) { + assert cur.predecessors().size() == 1; + prev = cur; + cur = cur.predecessors().get(0); + if (cur.predecessors().size() == 0) { + break; + } + } + + if (cur instanceof If) { + If ifNode = (If) cur; + if (ifNode.falseSuccessor() == prev) { + FixedNode successor = ifNode.trueSuccessor(); + BooleanNode condition = ifNode.compare(); + FixedGuard fixedGuard = new FixedGuard(graph); + fixedGuard.setNext(successor); + fixedGuard.setNode(condition); + ifNode.replaceAndDelete(fixedGuard); + lastInstr = null; + return fixed; + } + } else { + prev.replaceAtPredecessors(fixed); + lastInstr = null; + return fixed; + } + } lastInstr.setNext(fixed); lastInstr = null; return fixed;