--- a/hotspot/src/share/vm/opto/loopnode.cpp Thu Jun 16 13:46:55 2011 -0700
+++ b/hotspot/src/share/vm/opto/loopnode.cpp Mon Jun 20 16:45:35 2011 -0700
@@ -453,7 +453,12 @@
// Now we need to canonicalize loop condition.
if (bt == BoolTest::ne) {
assert(stride_con == 1 || stride_con == -1, "simple increment only");
- bt = (stride_con > 0) ? BoolTest::lt : BoolTest::gt;
+ // 'ne' can be replaced with 'lt' only when init < limit.
+ if (stride_con > 0 && init_t->_hi < limit_t->_lo)
+ bt = BoolTest::lt;
+ // 'ne' can be replaced with 'gt' only when init > limit.
+ if (stride_con < 0 && init_t->_lo > limit_t->_hi)
+ bt = BoolTest::gt;
}
if (incl_limit) {