src/share/vm/opto/loopTransform.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7068051 Sdiff src/share/vm/opto

src/share/vm/opto/loopTransform.cpp

Print this page




 492 #ifndef PRODUCT
 493       if (PrintOpto && VerifyLoopOptimizations) {
 494         tty->print("Peeling a 'main' loop; resetting to 'normal' ");
 495         loop->dump_head();
 496       }
 497 #endif
 498     }
 499   }
 500   Node* entry = head->in(LoopNode::EntryControl);
 501 
 502   // Step 1: Clone the loop body.  The clone becomes the peeled iteration.
 503   //         The pre-loop illegally has 2 control users (old & new loops).
 504   clone_loop( loop, old_new, dom_depth(head) );
 505 
 506   // Step 2: Make the old-loop fall-in edges point to the peeled iteration.
 507   //         Do this by making the old-loop fall-in edges act as if they came
 508   //         around the loopback from the prior iteration (follow the old-loop
 509   //         backedges) and then map to the new peeled iteration.  This leaves
 510   //         the pre-loop with only 1 user (the new peeled iteration), but the
 511   //         peeled-loop backedge has 2 users.
 512   Node* new_exit_value = old_new[head->in(LoopNode::LoopBackControl)->_idx];
 513   new_exit_value = move_loop_predicates(entry, new_exit_value, !counted_loop);
 514   _igvn.hash_delete(head);
 515   head->set_req(LoopNode::EntryControl, new_exit_value);
 516   for (DUIterator_Fast jmax, j = head->fast_outs(jmax); j < jmax; j++) {
 517     Node* old = head->fast_out(j);
 518     if (old->in(0) == loop->_head && old->req() == 3 && old->is_Phi()) {
 519       new_exit_value = old_new[old->in(LoopNode::LoopBackControl)->_idx];
 520       if (!new_exit_value )     // Backedge value is ALSO loop invariant?
 521         // Then loop body backedge value remains the same.
 522         new_exit_value = old->in(LoopNode::LoopBackControl);
 523       _igvn.hash_delete(old);
 524       old->set_req(LoopNode::EntryControl, new_exit_value);
 525     }
 526   }
 527 
 528 
 529   // Step 3: Cut the backedge on the clone (so its not a loop) and remove the
 530   //         extra backedge user.
 531   Node* new_head = old_new[head->_idx];
 532   _igvn.hash_delete(new_head);
 533   new_head->set_req(LoopNode::LoopBackControl, C->top());
 534   for (DUIterator_Fast j2max, j2 = new_head->fast_outs(j2max); j2 < j2max; j2++) {
 535     Node* use = new_head->fast_out(j2);
 536     if (use->in(0) == new_head && use->req() == 3 && use->is_Phi()) {
 537       _igvn.hash_delete(use);
 538       use->set_req(LoopNode::LoopBackControl, C->top());
 539     }




 492 #ifndef PRODUCT
 493       if (PrintOpto && VerifyLoopOptimizations) {
 494         tty->print("Peeling a 'main' loop; resetting to 'normal' ");
 495         loop->dump_head();
 496       }
 497 #endif
 498     }
 499   }
 500   Node* entry = head->in(LoopNode::EntryControl);
 501 
 502   // Step 1: Clone the loop body.  The clone becomes the peeled iteration.
 503   //         The pre-loop illegally has 2 control users (old & new loops).
 504   clone_loop( loop, old_new, dom_depth(head) );
 505 
 506   // Step 2: Make the old-loop fall-in edges point to the peeled iteration.
 507   //         Do this by making the old-loop fall-in edges act as if they came
 508   //         around the loopback from the prior iteration (follow the old-loop
 509   //         backedges) and then map to the new peeled iteration.  This leaves
 510   //         the pre-loop with only 1 user (the new peeled iteration), but the
 511   //         peeled-loop backedge has 2 users.
 512   Node* new_entry = old_new[head->in(LoopNode::LoopBackControl)->_idx];

 513   _igvn.hash_delete(head);
 514   head->set_req(LoopNode::EntryControl, new_entry);
 515   for (DUIterator_Fast jmax, j = head->fast_outs(jmax); j < jmax; j++) {
 516     Node* old = head->fast_out(j);
 517     if (old->in(0) == loop->_head && old->req() == 3 && old->is_Phi()) {
 518       Node* new_exit_value = old_new[old->in(LoopNode::LoopBackControl)->_idx];
 519       if (!new_exit_value )     // Backedge value is ALSO loop invariant?
 520         // Then loop body backedge value remains the same.
 521         new_exit_value = old->in(LoopNode::LoopBackControl);
 522       _igvn.hash_delete(old);
 523       old->set_req(LoopNode::EntryControl, new_exit_value);
 524     }
 525   }
 526 
 527 
 528   // Step 3: Cut the backedge on the clone (so its not a loop) and remove the
 529   //         extra backedge user.
 530   Node* new_head = old_new[head->_idx];
 531   _igvn.hash_delete(new_head);
 532   new_head->set_req(LoopNode::LoopBackControl, C->top());
 533   for (DUIterator_Fast j2max, j2 = new_head->fast_outs(j2max); j2 < j2max; j2++) {
 534     Node* use = new_head->fast_out(j2);
 535     if (use->in(0) == new_head && use->req() == 3 && use->is_Phi()) {
 536       _igvn.hash_delete(use);
 537       use->set_req(LoopNode::LoopBackControl, C->top());
 538     }


src/share/vm/opto/loopTransform.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File