622 |
622 |
623 return true; // Do maximally unroll |
623 return true; // Do maximally unroll |
624 } |
624 } |
625 |
625 |
626 |
626 |
627 #define MAX_UNROLL 16 // maximum number of unrolls for main loop |
|
628 |
|
629 //------------------------------policy_unroll---------------------------------- |
627 //------------------------------policy_unroll---------------------------------- |
630 // Return TRUE or FALSE if the loop should be unrolled or not. Unroll if |
628 // Return TRUE or FALSE if the loop should be unrolled or not. Unroll if |
631 // the loop is a CountedLoop and the body is small enough. |
629 // the loop is a CountedLoop and the body is small enough. |
632 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { |
630 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { |
633 |
631 |
640 // Protect against over-unrolling. |
638 // Protect against over-unrolling. |
641 // After split at least one iteration will be executed in pre-loop. |
639 // After split at least one iteration will be executed in pre-loop. |
642 if (cl->trip_count() <= (uint)(cl->is_normal_loop() ? 2 : 1)) return false; |
640 if (cl->trip_count() <= (uint)(cl->is_normal_loop() ? 2 : 1)) return false; |
643 |
641 |
644 int future_unroll_ct = cl->unrolled_count() * 2; |
642 int future_unroll_ct = cl->unrolled_count() * 2; |
645 if (future_unroll_ct > MAX_UNROLL) return false; |
643 if (future_unroll_ct > LoopMaxUnroll) return false; |
646 |
644 |
647 // Check for initial stride being a small enough constant |
645 // Check for initial stride being a small enough constant |
648 if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false; |
646 if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false; |
649 |
647 |
650 // Don't unroll if the next round of unrolling would push us |
648 // Don't unroll if the next round of unrolling would push us |