# HG changeset patch # User Roland Schatz # Date 1375954221 -7200 # Node ID acf09b065eba90d5e042879320f6285e6600f1c4 # Parent c4703de83626b5e5b3ef8b1dd7f46f1f9660b8f6 Calculate exit value of counted loop induction variables. diff -r c4703de83626 -r acf09b065eba graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Tue Aug 06 14:44:36 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Thu Aug 08 11:30:21 2013 +0200 @@ -131,6 +131,12 @@ } @Override + public ValueNode exitValueNode() { + ValueNode maxTripCount = loop.counted().maxTripCountNode(false); + return IntegerArithmeticNode.add(IntegerArithmeticNode.mul(strideNode(), maxTripCount), initNode()); + } + + @Override public boolean isConstantExtremum() { return isConstantInit() && isConstantStride() && loop.counted().isConstantMaxTripCount(); } diff -r c4703de83626 -r acf09b065eba graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Tue Aug 06 14:44:36 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java Thu Aug 08 11:30:21 2013 +0200 @@ -92,6 +92,11 @@ } @Override + public ValueNode exitValueNode() { + return op(base.exitValueNode(), offset); + } + + @Override public boolean isConstantExtremum() { return offset.isConstant() && base.isConstantExtremum(); } diff -r c4703de83626 -r acf09b065eba graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java Tue Aug 06 14:44:36 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java Thu Aug 08 11:30:21 2013 +0200 @@ -102,6 +102,11 @@ } @Override + public ValueNode exitValueNode() { + return IntegerArithmeticNode.mul(base.exitValueNode(), scale); + } + + @Override public boolean isConstantExtremum() { return scale.isConstant() && base.isConstantExtremum(); } diff -r c4703de83626 -r acf09b065eba graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Tue Aug 06 14:44:36 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java Thu Aug 08 11:30:21 2013 +0200 @@ -26,6 +26,9 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +/** + * This class describes a value node that is an induction variable in a counted loop. + */ public abstract class InductionVariable { public enum Direction { @@ -55,10 +58,20 @@ public abstract Direction direction(); + /** + * Returns the value node that is described by this InductionVariable instance. + */ public abstract ValueNode valueNode(); + /** + * Returns the node that gives the initial value of this induction variable. + */ public abstract ValueNode initNode(); + /** + * Returns the stride of the induction variable. The stride is the value that is added to the + * induction variable at each iteration. + */ public abstract ValueNode strideNode(); public abstract boolean isConstantInit(); @@ -69,6 +82,10 @@ public abstract long constantStride(); + /** + * Returns the extremum value of the induction variable. The extremum value is the value of the + * induction variable in the loop body of the last iteration. + */ public ValueNode extremumNode() { return extremumNode(false, valueNode().kind()); } @@ -78,4 +95,10 @@ public abstract boolean isConstantExtremum(); public abstract long constantExtremum(); + + /** + * Returns the exit value of the induction variable. The exit value is the value of the + * induction variable at the loop exit. + */ + public abstract ValueNode exitValueNode(); }