1713 Node *base = derived->in(AddPNode::Base);
1714 derived_base_map[derived->_idx] = base;
1715 return base;
1716 }
1717
1718 // Recursively find bases for Phis.
1719 // First check to see if we can avoid a base Phi here.
1720 Node *base = find_base_for_derived( derived_base_map, derived->in(1),maxlrg);
1721 uint i;
1722 for( i = 2; i < derived->req(); i++ )
1723 if( base != find_base_for_derived( derived_base_map,derived->in(i),maxlrg))
1724 break;
1725 // Went to the end without finding any different bases?
1726 if( i == derived->req() ) { // No need for a base Phi here
1727 derived_base_map[derived->_idx] = base;
1728 return base;
1729 }
1730
1731 // Now we see we need a base-Phi here to merge the bases
1732 const Type *t = base->bottom_type();
1733 base = new (C) PhiNode( derived->in(0), t );
1734 for( i = 1; i < derived->req(); i++ ) {
1735 base->init_req(i, find_base_for_derived(derived_base_map, derived->in(i), maxlrg));
1736 t = t->meet(base->in(i)->bottom_type());
1737 }
1738 base->as_Phi()->set_type(t);
1739
1740 // Search the current block for an existing base-Phi
1741 Block *b = _cfg.get_block_for_node(derived);
1742 for( i = 1; i <= b->end_idx(); i++ ) {// Search for matching Phi
1743 Node *phi = b->get_node(i);
1744 if( !phi->is_Phi() ) { // Found end of Phis with no match?
1745 b->insert_node(base, i); // Must insert created Phi here as base
1746 _cfg.map_node_to_block(base, b);
1747 new_lrg(base,maxlrg++);
1748 break;
1749 }
1750 // See if Phi matches.
1751 uint j;
1752 for( j = 1; j < base->req(); j++ )
1753 if( phi->in(j) != base->in(j) &&
1783 IndexSet liveout(_live->live(block));
1784
1785 for (uint j = block->end_idx() + 1; j > 1; j--) {
1786 Node* n = block->get_node(j - 1);
1787
1788 // Pre-split compares of loop-phis. Loop-phis form a cycle we would
1789 // like to see in the same register. Compare uses the loop-phi and so
1790 // extends its live range BUT cannot be part of the cycle. If this
1791 // extended live range overlaps with the update of the loop-phi value
1792 // we need both alive at the same time -- which requires at least 1
1793 // copy. But because Intel has only 2-address registers we end up with
1794 // at least 2 copies, one before the loop-phi update instruction and
1795 // one after. Instead we split the input to the compare just after the
1796 // phi.
1797 if( n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CmpI ) {
1798 Node *phi = n->in(1);
1799 if( phi->is_Phi() && phi->as_Phi()->region()->is_Loop() ) {
1800 Block *phi_block = _cfg.get_block_for_node(phi);
1801 if (_cfg.get_block_for_node(phi_block->pred(2)) == block) {
1802 const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI];
1803 Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask);
1804 insert_proj( phi_block, 1, spill, maxlrg++ );
1805 n->set_req(1,spill);
1806 must_recompute_live = true;
1807 }
1808 }
1809 }
1810
1811 // Get value being defined
1812 uint lidx = _lrg_map.live_range_id(n);
1813 // Ignore the occasional brand-new live range
1814 if (lidx && lidx < _lrg_map.max_lrg_id()) {
1815 // Remove from live-out set
1816 liveout.remove(lidx);
1817
1818 // Copies do not define a new value and so do not interfere.
1819 // Remove the copies source from the liveout set before interfering.
1820 uint idx = n->is_Copy();
1821 if (idx) {
1822 liveout.remove(_lrg_map.live_range_id(n->in(idx)));
1823 }
|
1713 Node *base = derived->in(AddPNode::Base);
1714 derived_base_map[derived->_idx] = base;
1715 return base;
1716 }
1717
1718 // Recursively find bases for Phis.
1719 // First check to see if we can avoid a base Phi here.
1720 Node *base = find_base_for_derived( derived_base_map, derived->in(1),maxlrg);
1721 uint i;
1722 for( i = 2; i < derived->req(); i++ )
1723 if( base != find_base_for_derived( derived_base_map,derived->in(i),maxlrg))
1724 break;
1725 // Went to the end without finding any different bases?
1726 if( i == derived->req() ) { // No need for a base Phi here
1727 derived_base_map[derived->_idx] = base;
1728 return base;
1729 }
1730
1731 // Now we see we need a base-Phi here to merge the bases
1732 const Type *t = base->bottom_type();
1733 base = new PhiNode( derived->in(0), t );
1734 for( i = 1; i < derived->req(); i++ ) {
1735 base->init_req(i, find_base_for_derived(derived_base_map, derived->in(i), maxlrg));
1736 t = t->meet(base->in(i)->bottom_type());
1737 }
1738 base->as_Phi()->set_type(t);
1739
1740 // Search the current block for an existing base-Phi
1741 Block *b = _cfg.get_block_for_node(derived);
1742 for( i = 1; i <= b->end_idx(); i++ ) {// Search for matching Phi
1743 Node *phi = b->get_node(i);
1744 if( !phi->is_Phi() ) { // Found end of Phis with no match?
1745 b->insert_node(base, i); // Must insert created Phi here as base
1746 _cfg.map_node_to_block(base, b);
1747 new_lrg(base,maxlrg++);
1748 break;
1749 }
1750 // See if Phi matches.
1751 uint j;
1752 for( j = 1; j < base->req(); j++ )
1753 if( phi->in(j) != base->in(j) &&
1783 IndexSet liveout(_live->live(block));
1784
1785 for (uint j = block->end_idx() + 1; j > 1; j--) {
1786 Node* n = block->get_node(j - 1);
1787
1788 // Pre-split compares of loop-phis. Loop-phis form a cycle we would
1789 // like to see in the same register. Compare uses the loop-phi and so
1790 // extends its live range BUT cannot be part of the cycle. If this
1791 // extended live range overlaps with the update of the loop-phi value
1792 // we need both alive at the same time -- which requires at least 1
1793 // copy. But because Intel has only 2-address registers we end up with
1794 // at least 2 copies, one before the loop-phi update instruction and
1795 // one after. Instead we split the input to the compare just after the
1796 // phi.
1797 if( n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CmpI ) {
1798 Node *phi = n->in(1);
1799 if( phi->is_Phi() && phi->as_Phi()->region()->is_Loop() ) {
1800 Block *phi_block = _cfg.get_block_for_node(phi);
1801 if (_cfg.get_block_for_node(phi_block->pred(2)) == block) {
1802 const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI];
1803 Node *spill = new MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask);
1804 insert_proj( phi_block, 1, spill, maxlrg++ );
1805 n->set_req(1,spill);
1806 must_recompute_live = true;
1807 }
1808 }
1809 }
1810
1811 // Get value being defined
1812 uint lidx = _lrg_map.live_range_id(n);
1813 // Ignore the occasional brand-new live range
1814 if (lidx && lidx < _lrg_map.max_lrg_id()) {
1815 // Remove from live-out set
1816 liveout.remove(lidx);
1817
1818 // Copies do not define a new value and so do not interfere.
1819 // Remove the copies source from the liveout set before interfering.
1820 uint idx = n->is_Copy();
1821 if (idx) {
1822 liveout.remove(_lrg_map.live_range_id(n->in(idx)));
1823 }
|