# HG changeset patch # User Lukas Stadler # Date 1406118257 -7200 # Node ID 4209ec855c1ccb1b6af6c3c76891a58b28b0842c # Parent 173da8c3095dcecf55500efe948ccb89f412722a cleanups and doc for PhiNode.singleValue diff -r 173da8c3095d -r 4209ec855c1c graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Wed Jul 23 14:20:27 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Wed Jul 23 14:24:17 2014 +0200 @@ -51,7 +51,7 @@ AbstractEndNode forwardEnd = loopBegin.forwardEnd(); for (PhiNode phi : loopBegin.phis()) { ValueNode backValue = phi.singleBackValue(); - if (backValue == PhiNode.NO_VALUE) { + if (backValue == PhiNode.MULTIPLE_VALUES) { continue; } ValueNode stride = addSub(backValue, phi); diff -r 173da8c3095d -r 4209ec855c1c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Wed Jul 23 14:20:27 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Wed Jul 23 14:24:17 2014 +0200 @@ -137,10 +137,15 @@ values().remove(index); } - public static final ValueNode NO_VALUE = new ValueNode(null) { + public static final ValueNode MULTIPLE_VALUES = new ValueNode(null) { // empty dummy class }; + /** + * If all inputs are the same value, this value is returned, otherwise {@link #MULTIPLE_VALUES}. + * Note that {@code null} is a valid return value, since {@link GuardPhiNode}s can have + * {@code null} inputs. + */ public ValueNode singleValue() { Iterator iterator = values().iterator(); ValueNode singleValue = iterator.next(); @@ -148,13 +153,18 @@ ValueNode value = iterator.next(); if (value != this) { if (value != singleValue) { - return NO_VALUE; + return MULTIPLE_VALUES; } } } return singleValue; } + /** + * If all inputs (but the first one) are the same value, this value is returned, otherwise + * {@link #MULTIPLE_VALUES}. Note that {@code null} is a valid return value, since + * {@link GuardPhiNode}s can have {@code null} inputs. + */ public ValueNode singleBackValue() { assert merge() instanceof LoopBeginNode; Iterator iterator = values().iterator(); @@ -162,7 +172,7 @@ ValueNode singleValue = iterator.next(); while (iterator.hasNext()) { if (iterator.next() != singleValue) { - return NO_VALUE; + return MULTIPLE_VALUES; } } return singleValue; @@ -172,7 +182,7 @@ public void simplify(SimplifierTool tool) { ValueNode singleValue = singleValue(); - if (singleValue != NO_VALUE) { + if (singleValue != MULTIPLE_VALUES) { for (Node node : usages().snapshot()) { if (node instanceof ProxyNode && ((ProxyNode) node).proxyPoint() instanceof LoopExitNode && ((LoopExitNode) ((ProxyNode) node).proxyPoint()).loopBegin() == merge) { tool.addToWorkList(node.usages()); diff -r 173da8c3095d -r 4209ec855c1c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Wed Jul 23 14:20:27 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Wed Jul 23 14:24:17 2014 +0200 @@ -174,7 +174,7 @@ } ValueNode singleValue = phiNode.singleValue(); - if (singleValue != PhiNode.NO_VALUE) { + if (singleValue != PhiNode.MULTIPLE_VALUES) { Collection phiUsages = phiNode.usages().filter(PhiNode.class).snapshot(); Collection proxyUsages = phiNode.usages().filter(ProxyNode.class).snapshot(); phiNode.graph().replaceFloating(phiNode, singleValue); @@ -343,7 +343,7 @@ v = ((ValueProxy) v).getOriginalNode(); } else if (v instanceof PhiNode) { v = ((PhiNode) v).singleValue(); - if (v == PhiNode.NO_VALUE) { + if (v == PhiNode.MULTIPLE_VALUES) { v = null; } } else {