hotspot/src/share/vm/opto/loopnode.cpp
changeset 10005 ce4ea81a1329
parent 9446 748a37b25d10
child 10258 10c77b8c8d3e
--- 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) {