1.1 --- a/src/share/vm/opto/loopTransform.cpp Thu Apr 28 14:00:13 2011 -0700 1.2 +++ b/src/share/vm/opto/loopTransform.cpp Thu Apr 28 16:40:23 2011 -0700 1.3 @@ -632,6 +632,8 @@ 1.4 } 1.5 1.6 1.7 +#define MAX_UNROLL 16 // maximum number of unrolls for main loop 1.8 + 1.9 //------------------------------policy_unroll---------------------------------- 1.10 // Return TRUE or FALSE if the loop should be unrolled or not. Unroll if 1.11 // the loop is a CountedLoop and the body is small enough. 1.12 @@ -646,10 +648,11 @@ 1.13 // protect against over-unrolling 1.14 if (cl->trip_count() <= 1) return false; 1.15 1.16 - // Check for stride being a small enough constant 1.17 - if (abs(cl->stride_con()) > (1<<3)) return false; 1.18 + int future_unroll_ct = cl->unrolled_count() * 2; 1.19 + if (future_unroll_ct > MAX_UNROLL) return false; 1.20 1.21 - int future_unroll_ct = cl->unrolled_count() * 2; 1.22 + // Check for initial stride being a small enough constant 1.23 + if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false; 1.24 1.25 // Don't unroll if the next round of unrolling would push us 1.26 // over the expected trip count of the loop. One is subtracted