changeset 13750:a03cb658e68e

only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 24 Jan 2014 12:26:05 +0100
parents 962f06a1a387
children 9de3efd2ea8f 34ab58984118 e076c87ab175
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Fri Jan 24 01:19:52 2014 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Fri Jan 24 12:26:05 2014 +0100
@@ -109,11 +109,6 @@
             if (c.getValue() != negated) {
                 return graph().start();
             }
-        } else if (negated && condition() instanceof ShortCircuitOrNode) {
-            ShortCircuitOrNode or = (ShortCircuitOrNode) condition();
-            GuardNode firstGuard = graph().unique(new GuardNode(or.getX(), getGuard(), reason, action, !or.isXNegated(), speculation));
-            GuardNode secondGuard = graph().unique(new GuardNode(or.getY(), firstGuard, reason, action, !or.isYNegated(), speculation));
-            return secondGuard;
         }
         return this;
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Fri Jan 24 01:19:52 2014 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Fri Jan 24 12:26:05 2014 +0100
@@ -315,9 +315,18 @@
 
         private void registerCondition(boolean isTrue, LogicNode condition, ValueNode anchor) {
             if (!isTrue && condition instanceof ShortCircuitOrNode) {
-                ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition;
-                registerCondition(disjunction.isXNegated(), disjunction.getX(), anchor);
-                registerCondition(disjunction.isYNegated(), disjunction.getY(), anchor);
+                /*
+                 * We can only do this for fixed nodes, because floating guards will be registered
+                 * at a BeginNode but might be "valid" only later due to data flow dependencies.
+                 * Therefore, registering both conditions of a ShortCircuitOrNode for a floating
+                 * guard could lead to cycles in data flow, because the guard will be used as anchor
+                 * for both conditions, and one condition could be depending on the other.
+                 */
+                if (anchor instanceof FixedNode) {
+                    ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition;
+                    registerCondition(disjunction.isXNegated(), disjunction.getX(), anchor);
+                    registerCondition(disjunction.isYNegated(), disjunction.getY(), anchor);
+                }
             }
             state.addCondition(isTrue, condition, anchor);