Mercurial > hg > graal-compiler
changeset 22086:660aa109e456
Simplify maxTripCountNode method.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 25 Jun 2015 13:17:08 +0200 |
parents | 1a769bce9a01 |
children | ba177df8f5aa |
files | graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java |
diffstat | 1 files changed, 14 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java Mon Jun 22 11:42:54 2015 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java Thu Jun 25 13:17:08 2015 +0200 @@ -56,26 +56,21 @@ StructuredGraph graph = iv.valueNode().graph(); Stamp stamp = iv.valueNode().stamp(); ValueNode range = sub(graph, end, iv.initNode()); - if (!iv.isConstantStride() || Math.abs(iv.constantStride()) != 1) { - ValueNode stride = iv.strideNode(); - if (!oneOff) { - if (iv.direction() == Direction.Up) { - stride = sub(graph, stride, ConstantNode.forIntegerStamp(stamp, 1, graph)); - } else { - assert iv.direction() == Direction.Down; - stride = add(graph, stride, ConstantNode.forIntegerStamp(stamp, 1, graph)); - } - } - range = add(graph, range, stride); - } else if (oneOff) { - if (iv.direction() == Direction.Up) { - range = add(graph, range, ConstantNode.forIntegerStamp(stamp, 1, graph)); - } else { - assert iv.direction() == Direction.Down; - range = sub(graph, range, ConstantNode.forIntegerStamp(stamp, 1, graph)); - } + + ValueNode oneDirection; + if (iv.direction() == Direction.Up) { + oneDirection = ConstantNode.forIntegerStamp(stamp, 1, graph); + } else { + assert iv.direction() == Direction.Down; + oneDirection = ConstantNode.forIntegerStamp(stamp, -1, graph); } - ValueNode div = divBefore(graph, loop.entryPoint(), range, iv.strideNode()); + if (oneOff) { + range = add(graph, range, oneDirection); + } + // round-away-from-zero divison: (range + stride -/+ 1) / stride + ValueNode denominator = add(graph, sub(graph, range, oneDirection), iv.strideNode()); + ValueNode div = divBefore(graph, loop.entryPoint(), denominator, iv.strideNode()); + if (assumePositive) { return div; }