changeset 19582:da62d18a9da0

Small improvement to mod/div peephole optimization.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 24 Feb 2015 15:10:11 +0100
parents 67d16e135ac2
children a148dec4e37b
files graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Tue Feb 24 14:09:40 2015 +0100
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Tue Feb 24 15:10:11 2015 +0100
@@ -61,7 +61,21 @@
         if ((valueNode instanceof IntegerDivNode) || (valueNode instanceof IntegerRemNode)) {
             FixedBinaryNode divRem = (FixedBinaryNode) valueNode;
             FixedNode node = divRem.next();
-            while (node instanceof FixedWithNextNode) {
+            while (true) {
+                if (node instanceof IfNode) {
+                    IfNode ifNode = (IfNode) node;
+                    double probability = ifNode.getTrueSuccessorProbability();
+                    if (probability == 1.0) {
+                        node = ifNode.trueSuccessor();
+                    } else if (probability == 0.0) {
+                        node = ifNode.falseSuccessor();
+                    } else {
+                        break;
+                    }
+                } else if (!(node instanceof FixedWithNextNode)) {
+                    break;
+                }
+
                 FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) node;
                 if (((fixedWithNextNode instanceof IntegerDivNode) || (fixedWithNextNode instanceof IntegerRemNode)) && fixedWithNextNode.getClass() != divRem.getClass()) {
                     FixedBinaryNode otherDivRem = (FixedBinaryNode) fixedWithNextNode;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Tue Feb 24 14:09:40 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Tue Feb 24 15:10:11 2015 +0100
@@ -94,6 +94,10 @@
         return falseSuccessor;
     }
 
+    public double getTrueSuccessorProbability() {
+        return this.trueSuccessorProbability;
+    }
+
     public void setTrueSuccessor(AbstractBeginNode node) {
         updatePredecessor(trueSuccessor, node);
         trueSuccessor = node;