# HG changeset patch # User Lukas Stadler # Date 1403708101 -7200 # Node ID 8e82823712ba67317a9a39665bbb2f1a3239d87b # Parent 4182366b8eed03e67be33b0f397dac2a2656e630 let BranchProbabilityNode implement Simplifiable instead of Canonicalizable diff -r 4182366b8eed -r 8e82823712ba graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Wed Jun 25 16:55:01 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Wed Jun 25 16:55:01 2014 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; -import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; @@ -35,7 +34,7 @@ * the if node's taken probability. Then the branch probability node will be removed. This node is * intended primarily for snippets, so that they can define their fast and slow paths. */ -public class BranchProbabilityNode extends FloatingNode implements Canonicalizable, Lowerable { +public class BranchProbabilityNode extends FloatingNode implements Simplifiable, Lowerable { public static final double LIKELY_PROBABILITY = 0.6; public static final double NOT_LIKELY_PROBABILITY = 1 - LIKELY_PROBABILITY; @@ -67,7 +66,7 @@ } @Override - public Node canonical(CanonicalizerTool tool) { + public void simplify(SimplifierTool tool) { if (probability.isConstant()) { double probabilityValue = probability.asConstant().asDouble(); if (probabilityValue < 0.0) { @@ -94,15 +93,15 @@ } } } - if (!couldSet) { - if (isSubstitutionGraph()) { - return this; + if (couldSet) { + replaceAndDelete(condition); + tool.addToWorkList(condition.usages()); + } else { + if (!isSubstitutionGraph()) { + throw new GraalInternalError("Wrong usage of branch probability injection!"); } - throw new GraalInternalError("Wrong usage of branch probability injection!"); } - return condition; } - return this; } private boolean isSubstitutionGraph() {