Mercurial > hg > truffle
changeset 11263:acf09b065eba
Calculate exit value of counted loop induction variables.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 08 Aug 2013 11:30:21 +0200 |
parents | c4703de83626 |
children | 7894695caee6 |
files | graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariable.java |
diffstat | 4 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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(); }
--- 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(); }
--- 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(); }
--- 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(); }