@@ -1699,17 +1699,16 @@ bool IdealLoopTree::is_invariant(Node* n) const {
16991699
17001700// Search the Assertion Predicates added by loop predication and/or range check elimination and update them according
17011701// to the new stride.
1702- void PhaseIdealLoop::update_main_loop_assertion_predicates (CountedLoopNode* main_loop_head) {
1703- Node* init = main_loop_head->init_trip ();
1704-
1702+ void PhaseIdealLoop::update_main_loop_assertion_predicates (CountedLoopNode* new_main_loop_head,
1703+ const int stride_con_before_unroll) {
17051704 // Compute the value of the loop induction variable at the end of the
17061705 // first iteration of the unrolled loop: init + new_stride_con - init_inc
1707- int unrolled_stride_con = main_loop_head-> stride_con () * 2 ;
1706+ int unrolled_stride_con = stride_con_before_unroll * 2 ;
17081707 Node* unrolled_stride = intcon (unrolled_stride_con);
17091708
1710- Node* loop_entry = main_loop_head ->skip_strip_mined ()->in (LoopNode::EntryControl);
1709+ Node* loop_entry = new_main_loop_head ->skip_strip_mined ()->in (LoopNode::EntryControl);
17111710 PredicateIterator predicate_iterator (loop_entry);
1712- UpdateStrideForAssertionPredicates update_stride_for_assertion_predicates (unrolled_stride, this );
1711+ UpdateStrideForAssertionPredicates update_stride_for_assertion_predicates (unrolled_stride, new_main_loop_head, this );
17131712 predicate_iterator.for_each (update_stride_for_assertion_predicates);
17141713}
17151714
@@ -1748,9 +1747,9 @@ void PhaseIdealLoop::initialize_assertion_predicates_for_post_loop(CountedLoopNo
17481747}
17491748
17501749void PhaseIdealLoop::create_assertion_predicates_at_loop (CountedLoopNode* source_loop_head,
1751- CountedLoopNode* target_loop_head,
1752- const NodeInLoopBody& _node_in_loop_body,
1753- const bool clone_template) {
1750+ CountedLoopNode* target_loop_head,
1751+ const NodeInLoopBody& _node_in_loop_body,
1752+ const bool clone_template) {
17541753 CreateAssertionPredicatesVisitor create_assertion_predicates_visitor (target_loop_head, this , _node_in_loop_body,
17551754 clone_template);
17561755 Node* source_loop_entry = source_loop_head->skip_strip_mined ()->in (LoopNode::EntryControl);
@@ -1854,15 +1853,13 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
18541853 C->set_major_progress ();
18551854
18561855 Node* new_limit = nullptr ;
1857- int stride_con = stride->get_int ();
1856+ const int stride_con = stride->get_int ();
18581857 int stride_p = (stride_con > 0 ) ? stride_con : -stride_con;
18591858 uint old_trip_count = loop_head->trip_count ();
18601859 // Verify that unroll policy result is still valid.
18611860 assert (old_trip_count > 1 && (!adjust_min_trip || stride_p <=
18621861 MIN2<int >(max_jint / 2 - 2 , MAX2 (1 <<3 , Matcher::max_vector_size (T_BYTE)) * loop_head->unrolled_count ())), " sanity" );
18631862
1864- update_main_loop_assertion_predicates (loop_head);
1865-
18661863 // Adjust loop limit to keep valid iterations number after unroll.
18671864 // Use (limit - stride) instead of (((limit - init)/stride) & (-2))*stride
18681865 // which may overflow.
@@ -1996,7 +1993,7 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
19961993 phi ->set_req (LoopNode::LoopBackControl, C->top ());
19971994 }
19981995 }
1999- Node * clone_head = old_new[loop_head->_idx ];
1996+ CountedLoopNode* clone_head = old_new[loop_head->_idx ]-> as_CountedLoop () ;
20001997 _igvn.hash_delete (clone_head);
20011998 loop_head ->set_req (LoopNode:: EntryControl, clone_head->in (LoopNode::LoopBackControl));
20021999 clone_head->set_req (LoopNode::LoopBackControl, loop_head ->in (LoopNode::LoopBackControl));
@@ -2025,6 +2022,8 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
20252022 loop->record_for_igvn ();
20262023 loop_head->clear_strip_mined ();
20272024
2025+ update_main_loop_assertion_predicates (clone_head, stride_con);
2026+
20282027#ifndef PRODUCT
20292028 if (C->do_vector_loop () && (PrintOpto && (VerifyLoopOptimizations || TraceLoopOpts))) {
20302029 tty->print (" \n new loop after unroll\n " ); loop->dump_head ();
0 commit comments