Mercurial > hg > graal-compiler
changeset 16588:4209ec855c1c
cleanups and doc for PhiNode.singleValue
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Wed, 23 Jul 2014 14:24:17 +0200 |
parents | 173da8c3095d |
children | 6bdd2ec553eb |
files | graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java |
diffstat | 3 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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<ValueNode> 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<ValueNode> 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());
--- 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<PhiNode> phiUsages = phiNode.usages().filter(PhiNode.class).snapshot(); Collection<ProxyNode> 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 {