Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/loopTransform.cpp @ 401:ee8f06bfb27c
6743188: incomplete fix for 6700047 C2 failed in idom_no_update
Reviewed-by: rasbold, kvn
author | never |
---|---|
date | Fri, 03 Oct 2008 13:58:20 -0700 |
parents | cc80376deb0c |
children | a1980da045cc |
comparison
equal
deleted
inserted
replaced
400:cc80376deb0c | 401:ee8f06bfb27c |
---|---|
1588 } | 1588 } |
1589 | 1589 |
1590 | 1590 |
1591 //============================================================================= | 1591 //============================================================================= |
1592 //------------------------------iteration_split_impl--------------------------- | 1592 //------------------------------iteration_split_impl--------------------------- |
1593 void IdealLoopTree::iteration_split_impl( PhaseIdealLoop *phase, Node_List &old_new ) { | 1593 bool IdealLoopTree::iteration_split_impl( PhaseIdealLoop *phase, Node_List &old_new ) { |
1594 // Check and remove empty loops (spam micro-benchmarks) | 1594 // Check and remove empty loops (spam micro-benchmarks) |
1595 if( policy_do_remove_empty_loop(phase) ) | 1595 if( policy_do_remove_empty_loop(phase) ) |
1596 return; // Here we removed an empty loop | 1596 return true; // Here we removed an empty loop |
1597 | 1597 |
1598 bool should_peel = policy_peeling(phase); // Should we peel? | 1598 bool should_peel = policy_peeling(phase); // Should we peel? |
1599 | 1599 |
1600 bool should_unswitch = policy_unswitching(phase); | 1600 bool should_unswitch = policy_unswitching(phase); |
1601 | 1601 |
1602 // Non-counted loops may be peeled; exactly 1 iteration is peeled. | 1602 // Non-counted loops may be peeled; exactly 1 iteration is peeled. |
1603 // This removes loop-invariant tests (usually null checks). | 1603 // This removes loop-invariant tests (usually null checks). |
1604 if( !_head->is_CountedLoop() ) { // Non-counted loop | 1604 if( !_head->is_CountedLoop() ) { // Non-counted loop |
1605 if (PartialPeelLoop && phase->partial_peel(this, old_new)) { | 1605 if (PartialPeelLoop && phase->partial_peel(this, old_new)) { |
1606 return; | 1606 // Partial peel succeeded so terminate this round of loop opts |
1607 return false; | |
1607 } | 1608 } |
1608 if( should_peel ) { // Should we peel? | 1609 if( should_peel ) { // Should we peel? |
1609 #ifndef PRODUCT | 1610 #ifndef PRODUCT |
1610 if (PrintOpto) tty->print_cr("should_peel"); | 1611 if (PrintOpto) tty->print_cr("should_peel"); |
1611 #endif | 1612 #endif |
1612 phase->do_peeling(this,old_new); | 1613 phase->do_peeling(this,old_new); |
1613 } else if( should_unswitch ) { | 1614 } else if( should_unswitch ) { |
1614 phase->do_unswitching(this, old_new); | 1615 phase->do_unswitching(this, old_new); |
1615 } | 1616 } |
1616 return; | 1617 return true; |
1617 } | 1618 } |
1618 CountedLoopNode *cl = _head->as_CountedLoop(); | 1619 CountedLoopNode *cl = _head->as_CountedLoop(); |
1619 | 1620 |
1620 if( !cl->loopexit() ) return; // Ignore various kinds of broken loops | 1621 if( !cl->loopexit() ) return true; // Ignore various kinds of broken loops |
1621 | 1622 |
1622 // Do nothing special to pre- and post- loops | 1623 // Do nothing special to pre- and post- loops |
1623 if( cl->is_pre_loop() || cl->is_post_loop() ) return; | 1624 if( cl->is_pre_loop() || cl->is_post_loop() ) return true; |
1624 | 1625 |
1625 // Compute loop trip count from profile data | 1626 // Compute loop trip count from profile data |
1626 compute_profile_trip_cnt(phase); | 1627 compute_profile_trip_cnt(phase); |
1627 | 1628 |
1628 // Before attempting fancy unrolling, RCE or alignment, see if we want | 1629 // Before attempting fancy unrolling, RCE or alignment, see if we want |
1631 bool should_maximally_unroll = policy_maximally_unroll(phase); | 1632 bool should_maximally_unroll = policy_maximally_unroll(phase); |
1632 if( should_maximally_unroll ) { | 1633 if( should_maximally_unroll ) { |
1633 // Here we did some unrolling and peeling. Eventually we will | 1634 // Here we did some unrolling and peeling. Eventually we will |
1634 // completely unroll this loop and it will no longer be a loop. | 1635 // completely unroll this loop and it will no longer be a loop. |
1635 phase->do_maximally_unroll(this,old_new); | 1636 phase->do_maximally_unroll(this,old_new); |
1636 return; | 1637 return true; |
1637 } | 1638 } |
1638 if (should_unswitch) { | 1639 if (should_unswitch) { |
1639 phase->do_unswitching(this, old_new); | 1640 phase->do_unswitching(this, old_new); |
1640 return; | 1641 return true; |
1641 } | 1642 } |
1642 } | 1643 } |
1643 | 1644 |
1644 | 1645 |
1645 // Counted loops may be peeled, may need some iterations run up | 1646 // Counted loops may be peeled, may need some iterations run up |
1696 | 1697 |
1697 } else { // Else we have an unchanged counted loop | 1698 } else { // Else we have an unchanged counted loop |
1698 if( should_peel ) // Might want to peel but do nothing else | 1699 if( should_peel ) // Might want to peel but do nothing else |
1699 phase->do_peeling(this,old_new); | 1700 phase->do_peeling(this,old_new); |
1700 } | 1701 } |
1702 return true; | |
1701 } | 1703 } |
1702 | 1704 |
1703 | 1705 |
1704 //============================================================================= | 1706 //============================================================================= |
1705 //------------------------------iteration_split-------------------------------- | 1707 //------------------------------iteration_split-------------------------------- |
1706 void IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new ) { | 1708 bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new ) { |
1707 // Recursively iteration split nested loops | 1709 // Recursively iteration split nested loops |
1708 if( _child ) _child->iteration_split( phase, old_new ); | 1710 if( _child && !_child->iteration_split( phase, old_new )) |
1711 return false; | |
1709 | 1712 |
1710 // Clean out prior deadwood | 1713 // Clean out prior deadwood |
1711 DCE_loop_body(); | 1714 DCE_loop_body(); |
1712 | 1715 |
1713 | 1716 |
1725 if( !_child && // If not an inner loop, do not split | 1728 if( !_child && // If not an inner loop, do not split |
1726 !_irreducible && | 1729 !_irreducible && |
1727 _allow_optimizations && | 1730 _allow_optimizations && |
1728 !tail()->is_top() ) { // Also ignore the occasional dead backedge | 1731 !tail()->is_top() ) { // Also ignore the occasional dead backedge |
1729 if (!_has_call) { | 1732 if (!_has_call) { |
1730 iteration_split_impl( phase, old_new ); | 1733 if (!iteration_split_impl( phase, old_new )) { |
1734 return false; | |
1735 } | |
1731 } else if (policy_unswitching(phase)) { | 1736 } else if (policy_unswitching(phase)) { |
1732 phase->do_unswitching(this, old_new); | 1737 phase->do_unswitching(this, old_new); |
1733 } | 1738 } |
1734 } | 1739 } |
1735 | 1740 |
1736 // Minor offset re-organization to remove loop-fallout uses of | 1741 // Minor offset re-organization to remove loop-fallout uses of |
1737 // trip counter. | 1742 // trip counter. |
1738 if( _head->is_CountedLoop() ) phase->reorg_offsets( this ); | 1743 if( _head->is_CountedLoop() ) phase->reorg_offsets( this ); |
1739 if( _next ) _next->iteration_split( phase, old_new ); | 1744 if( _next && !_next->iteration_split( phase, old_new )) |
1740 } | 1745 return false; |
1746 return true; | |
1747 } |