# HG changeset patch # User Thomas Wuerthinger # Date 1425073766 -3600 # Node ID 312bf1b3f410614825fae42a383c7749705f6620 # Parent 5e31fe50d3300d5c3bbb3c4efd7ca727e773eb54 Support == as a loop exit condition of counted loops. diff -r 5e31fe50d330 -r 312bf1b3f410 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Fri Feb 27 15:34:43 2015 -0800 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Fri Feb 27 22:49:26 2015 +0100 @@ -175,13 +175,13 @@ negated = true; } LogicNode ifTest = ifNode.condition(); - if (!(ifTest instanceof IntegerLessThanNode)) { + if (!(ifTest instanceof IntegerLessThanNode) && !(ifTest instanceof IntegerEqualsNode)) { if (ifTest instanceof IntegerBelowNode) { Debug.log("Ignored potential Counted loop at %s with |<|", loopBegin); } return false; } - IntegerLessThanNode lessThan = (IntegerLessThanNode) ifTest; + CompareNode lessThan = (CompareNode) ifTest; Condition condition = null; InductionVariable iv = null; ValueNode limit = null; @@ -198,6 +198,9 @@ limit = lessThan.getY(); } } + if (iv != null && iv.constantStride() != 1 && !(ifTest instanceof IntegerLessThanNode)) { + return false; + } if (condition == null) { return false; } @@ -206,6 +209,24 @@ } boolean oneOff = false; switch (condition) { + case EQ: + return false; + case NE: { + IntegerStamp initStamp = (IntegerStamp) iv.initNode().stamp(); + IntegerStamp limitStamp = (IntegerStamp) limit.stamp(); + if (iv.direction() == Direction.Up) { + if (initStamp.upperBound() > limitStamp.lowerBound()) { + return false; + } + } else { + assert iv.direction() == Direction.Down; + if (initStamp.lowerBound() < limitStamp.upperBound()) { + return false; + } + } + oneOff = true; + break; + } case LE: oneOff = true; // fall through case LT: