changeset 23169:db2df49e2245

Canonicalize value proxies of loop phis.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 13 Dec 2015 17:11:44 +0100
parents 2ad910b35d66
children cce1287c1778
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java
diffstat 3 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Sun Dec 13 16:17:29 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Sun Dec 13 17:11:44 2015 +0100
@@ -59,11 +59,11 @@
         return super.verify();
     }
 
-    public static ValueProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
+    public static ValueProxyNode forValue(ValueNode value, LoopExitNode exit, StructuredGraph graph) {
         return graph.unique(new ValueProxyNode(value, exit));
     }
 
-    public static GuardProxyNode forGuard(GuardingNode value, AbstractBeginNode exit, StructuredGraph graph) {
+    public static GuardProxyNode forGuard(GuardingNode value, LoopExitNode exit, StructuredGraph graph) {
         return graph.unique(new GuardProxyNode(value, exit));
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Sun Dec 13 16:17:29 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Sun Dec 13 17:11:44 2015 +0100
@@ -38,9 +38,12 @@
     public static final NodeClass<ValueProxyNode> TYPE = NodeClass.create(ValueProxyNode.class);
     @Input ValueNode value;
 
+    private final boolean loopPhiProxy;
+
     public ValueProxyNode(ValueNode value, AbstractBeginNode proxyPoint) {
         super(TYPE, value.stamp(), proxyPoint);
         this.value = value;
+        loopPhiProxy = (proxyPoint instanceof LoopExitNode && value instanceof PhiNode && ((PhiNode) value).merge() == ((LoopExitNode) proxyPoint).loopBegin());
     }
 
     @Override
@@ -58,6 +61,13 @@
         if (value.isConstant()) {
             return value;
         }
+        if (loopPhiProxy && proxyPoint instanceof LoopExitNode) {
+            if (!(value instanceof PhiNode)) {
+                return value;
+            } else if (((PhiNode) value).merge() != ((LoopExitNode) proxyPoint).loopBegin()) {
+                return value;
+            }
+        }
         return this;
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Sun Dec 13 16:17:29 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Sun Dec 13 17:11:44 2015 +0100
@@ -184,7 +184,7 @@
 
             Node newGuard = guard;
             if (survivingSuccessor instanceof LoopExitNode) {
-                newGuard = ProxyNode.forGuard(guard, survivingSuccessor, graph);
+                newGuard = ProxyNode.forGuard(guard, (LoopExitNode) survivingSuccessor, graph);
             }
             survivingSuccessor.replaceAtUsages(InputType.Guard, newGuard);