7039652: Performance regression after 7004547 changes
authorkvn
Thu, 28 Apr 2011 16:40:23 -0700
changeset 9434 56d7158be6dc
parent 9332 2c0eaca39eb4
child 9435 b16821523fe3
7039652: Performance regression after 7004547 changes Summary: Use unrolled_count() to limit unrolling and use the stride check only for initial stride value. Reviewed-by: never
hotspot/src/share/vm/opto/loopTransform.cpp
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Thu Apr 28 14:00:13 2011 -0700
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Thu Apr 28 16:40:23 2011 -0700
@@ -632,6 +632,8 @@
 }
 
 
+#define MAX_UNROLL 16 // maximum number of unrolls for main loop
+
 //------------------------------policy_unroll----------------------------------
 // Return TRUE or FALSE if the loop should be unrolled or not.  Unroll if
 // the loop is a CountedLoop and the body is small enough.
@@ -646,10 +648,11 @@
   // protect against over-unrolling
   if (cl->trip_count() <= 1) return false;
 
-  // Check for stride being a small enough constant
-  if (abs(cl->stride_con()) > (1<<3)) return false;
+  int future_unroll_ct = cl->unrolled_count() * 2;
+  if (future_unroll_ct > MAX_UNROLL) return false;
 
-  int future_unroll_ct = cl->unrolled_count() * 2;
+  // Check for initial stride being a small enough constant
+  if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false;
 
   // Don't unroll if the next round of unrolling would push us
   // over the expected trip count of the loop.  One is subtracted