changeset 16221:8e82823712ba

let BranchProbabilityNode implement Simplifiable instead of Canonicalizable
author Lukas Stadler <lukas.stadler@oracle.com>
date Wed, 25 Jun 2014 16:55:01 +0200
parents 4182366b8eed
children 7a0035cbf808
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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() {