changeset 2474:ae93231c7a1f

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
author kvn
date Thu, 28 Apr 2011 16:40:23 -0700
parents 01fd6090fdd8
children b21ecca7ccc4
files src/share/vm/opto/loopTransform.cpp
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/loopTransform.cpp	Thu Apr 28 14:00:13 2011 -0700
+++ b/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