575 |
575 |
576 // Check for SafePoint on backedge and remove |
576 // Check for SafePoint on backedge and remove |
577 Node *sfpt = x->in(LoopNode::LoopBackControl); |
577 Node *sfpt = x->in(LoopNode::LoopBackControl); |
578 if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) { |
578 if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) { |
579 lazy_replace( sfpt, iftrue ); |
579 lazy_replace( sfpt, iftrue ); |
|
580 if (loop->_safepts != NULL) { |
|
581 loop->_safepts->yank(sfpt); |
|
582 } |
580 loop->_tail = iftrue; |
583 loop->_tail = iftrue; |
581 } |
584 } |
582 |
585 |
583 // Build a canonical trip test. |
586 // Build a canonical trip test. |
584 // Clone code, as old values may be in use. |
587 // Clone code, as old values may be in use. |
666 lazy_replace( x, l ); |
669 lazy_replace( x, l ); |
667 set_idom(l, init_control, dom_depth(x)); |
670 set_idom(l, init_control, dom_depth(x)); |
668 |
671 |
669 // Check for immediately preceding SafePoint and remove |
672 // Check for immediately preceding SafePoint and remove |
670 Node *sfpt2 = le->in(0); |
673 Node *sfpt2 = le->in(0); |
671 if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) |
674 if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) { |
672 lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control)); |
675 lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control)); |
|
676 if (loop->_safepts != NULL) { |
|
677 loop->_safepts->yank(sfpt2); |
|
678 } |
|
679 } |
673 |
680 |
674 // Free up intermediate goo |
681 // Free up intermediate goo |
675 _igvn.remove_dead_node(hook); |
682 _igvn.remove_dead_node(hook); |
676 |
683 |
677 #ifdef ASSERT |
684 #ifdef ASSERT |
1524 // is encountered, to find the ncsfpt's that are closest to the tail. |
1531 // is encountered, to find the ncsfpt's that are closest to the tail. |
1525 // |
1532 // |
1526 void IdealLoopTree::check_safepts(VectorSet &visited, Node_List &stack) { |
1533 void IdealLoopTree::check_safepts(VectorSet &visited, Node_List &stack) { |
1527 // Bottom up traversal |
1534 // Bottom up traversal |
1528 IdealLoopTree* ch = _child; |
1535 IdealLoopTree* ch = _child; |
1529 while (ch != NULL) { |
1536 if (_child) _child->check_safepts(visited, stack); |
1530 ch->check_safepts(visited, stack); |
1537 if (_next) _next ->check_safepts(visited, stack); |
1531 ch = ch->_next; |
|
1532 } |
|
1533 |
1538 |
1534 if (!_head->is_CountedLoop() && !_has_sfpt && _parent != NULL && !_irreducible) { |
1539 if (!_head->is_CountedLoop() && !_has_sfpt && _parent != NULL && !_irreducible) { |
1535 bool has_call = false; // call on dom-path |
1540 bool has_call = false; // call on dom-path |
1536 bool has_local_ncsfpt = false; // ncsfpt on dom-path at this loop depth |
1541 bool has_local_ncsfpt = false; // ncsfpt on dom-path at this loop depth |
1537 Node* nonlocal_ncsfpt = NULL; // ncsfpt on dom-path at a deeper depth |
1542 Node* nonlocal_ncsfpt = NULL; // ncsfpt on dom-path at a deeper depth |
1700 |
1705 |
1701 if (_head->is_CountedLoop() || |
1706 if (_head->is_CountedLoop() || |
1702 phase->is_counted_loop(_head, this)) { |
1707 phase->is_counted_loop(_head, this)) { |
1703 _has_sfpt = 1; // Indicate we do not need a safepoint here |
1708 _has_sfpt = 1; // Indicate we do not need a safepoint here |
1704 |
1709 |
1705 // Look for a safepoint to remove |
1710 // Look for safepoints to remove. |
1706 for (Node* n = tail(); n != _head; n = phase->idom(n)) |
1711 Node_List* sfpts = _safepts; |
1707 if (n->Opcode() == Op_SafePoint && phase->get_loop(n) == this && |
1712 if (sfpts != NULL) { |
1708 phase->is_deleteable_safept(n)) |
1713 for (uint i = 0; i < sfpts->size(); i++) { |
1709 phase->lazy_replace(n,n->in(TypeFunc::Control)); |
1714 Node* n = sfpts->at(i); |
|
1715 assert(phase->get_loop(n) == this, ""); |
|
1716 if (phase->is_deleteable_safept(n)) { |
|
1717 phase->lazy_replace(n, n->in(TypeFunc::Control)); |
|
1718 } |
|
1719 } |
|
1720 } |
1710 |
1721 |
1711 // Look for induction variables |
1722 // Look for induction variables |
1712 phase->replace_parallel_iv(this); |
1723 phase->replace_parallel_iv(this); |
1713 |
1724 |
1714 } else if (_parent != NULL && !_irreducible) { |
1725 } else if (_parent != NULL && !_irreducible) { |
1715 // Not a counted loop. |
1726 // Not a counted loop. |
1716 // Look for a safepoint on the idom-path to remove, preserving the first one |
1727 // Look for a safepoint on the idom-path. |
1717 bool found = false; |
1728 Node* sfpt = tail(); |
1718 Node* n = tail(); |
1729 for (; sfpt != _head; sfpt = phase->idom(sfpt)) { |
1719 for (; n != _head && !found; n = phase->idom(n)) { |
1730 if (sfpt->Opcode() == Op_SafePoint && phase->get_loop(sfpt) == this) |
1720 if (n->Opcode() == Op_SafePoint && phase->get_loop(n) == this) |
1731 break; // Found one |
1721 found = true; // Found one |
1732 } |
1722 } |
1733 // Delete other safepoints in this loop. |
1723 // Skip past it and delete the others |
1734 Node_List* sfpts = _safepts; |
1724 for (; n != _head; n = phase->idom(n)) { |
1735 if (sfpts != NULL && sfpt != _head && sfpt->Opcode() == Op_SafePoint) { |
1725 if (n->Opcode() == Op_SafePoint && phase->get_loop(n) == this && |
1736 for (uint i = 0; i < sfpts->size(); i++) { |
1726 phase->is_deleteable_safept(n)) |
1737 Node* n = sfpts->at(i); |
1727 phase->lazy_replace(n,n->in(TypeFunc::Control)); |
1738 assert(phase->get_loop(n) == this, ""); |
|
1739 if (n != sfpt && phase->is_deleteable_safept(n)) { |
|
1740 phase->lazy_replace(n, n->in(TypeFunc::Control)); |
|
1741 } |
|
1742 } |
1728 } |
1743 } |
1729 } |
1744 } |
1730 |
1745 |
1731 // Recursively |
1746 // Recursively |
1732 if (_child) _child->counted_loop( phase ); |
1747 if (_child) _child->counted_loop( phase ); |
2764 // Disable loop optimizations if the loop has a scalar replaceable |
2779 // Disable loop optimizations if the loop has a scalar replaceable |
2765 // allocation. This disabling may cause a potential performance lost |
2780 // allocation. This disabling may cause a potential performance lost |
2766 // if the allocation is not eliminated for some reason. |
2781 // if the allocation is not eliminated for some reason. |
2767 innermost->_allow_optimizations = false; |
2782 innermost->_allow_optimizations = false; |
2768 innermost->_has_call = 1; // = true |
2783 innermost->_has_call = 1; // = true |
|
2784 } else if (n->Opcode() == Op_SafePoint) { |
|
2785 // Record all safepoints in this loop. |
|
2786 if (innermost->_safepts == NULL) innermost->_safepts = new Node_List(); |
|
2787 innermost->_safepts->push(n); |
2769 } |
2788 } |
2770 } |
2789 } |
2771 } |
2790 } |
2772 |
2791 |
2773 // Flag as post-visited now |
2792 // Flag as post-visited now |
2814 // and thus could be avoided indefinitely) |
2833 // and thus could be avoided indefinitely) |
2815 if( !_verify_only && !_verify_me && ilt->_has_sfpt && n->Opcode() == Op_SafePoint && |
2834 if( !_verify_only && !_verify_me && ilt->_has_sfpt && n->Opcode() == Op_SafePoint && |
2816 is_deleteable_safept(n)) { |
2835 is_deleteable_safept(n)) { |
2817 Node *in = n->in(TypeFunc::Control); |
2836 Node *in = n->in(TypeFunc::Control); |
2818 lazy_replace(n,in); // Pull safepoint now |
2837 lazy_replace(n,in); // Pull safepoint now |
|
2838 if (ilt->_safepts != NULL) { |
|
2839 ilt->_safepts->yank(n); |
|
2840 } |
2819 // Carry on with the recursion "as if" we are walking |
2841 // Carry on with the recursion "as if" we are walking |
2820 // only the control input |
2842 // only the control input |
2821 if( !visited.test_set( in->_idx ) ) { |
2843 if( !visited.test_set( in->_idx ) ) { |
2822 worklist.push(in); // Visit this guy later, using worklist |
2844 worklist.push(in); // Visit this guy later, using worklist |
2823 } |
2845 } |