1616 1617 1618 //------------------------------Ideal------------------------------------------ 1619 // Return a node which is more "ideal" than the current node. Must preserve 1620 // the CFG, but we can still strip out dead paths. 1621 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1622 // The next should never happen after 6297035 fix. 1623 if( is_copy() ) // Already degraded to a Copy ? 1624 return NULL; // No change 1625 1626 Node *r = in(0); // RegionNode 1627 assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge"); 1628 1629 // Note: During parsing, phis are often transformed before their regions. 1630 // This means we have to use type_or_null to defend against untyped regions. 1631 if( phase->type_or_null(r) == Type::TOP ) // Dead code? 1632 return NULL; // No change 1633 1634 // If all inputs are value types, push the value type node down through the 1635 // phi because value type nodes should be merged through their input values. 1636 bool all_vt = true; 1637 for (uint i = 1; i < req() && all_vt; ++i) { 1638 all_vt = in(i) && in(i)->is_ValueType(); 1639 } 1640 if (req() > 2 && all_vt) { 1641 ValueTypeNode* vt = in(1)->as_ValueType()->clone_with_phis(phase, in(0)); 1642 for (uint i = 2; i < req(); ++i) { 1643 vt->merge_with(phase, in(i)->as_ValueType(), i, i == (req()-1)); 1644 } 1645 return vt; 1646 } 1647 1648 Node *top = phase->C->top(); 1649 bool new_phi = (outcnt() == 0); // transforming new Phi 1650 // No change for igvn if new phi is not hooked 1651 if (new_phi && can_reshape) 1652 return NULL; 1653 1654 // The are 2 situations when only one valid phi's input is left 1655 // (in addition to Region input). 1656 // One: region is not loop - replace phi with this input. 1657 // Two: region is loop - replace phi with top since this data path is dead 1658 // and we need to break the dead data loop. 1659 Node* progress = NULL; // Record if any progress made 1660 for( uint j = 1; j < req(); ++j ){ // For all paths in 1661 // Check unreachable control paths 1662 Node* rc = r->in(j); 1663 Node* n = in(j); // Get the input 1664 if (rc == NULL || phase->type(rc) == Type::TOP) { 1665 if (n != top) { // Not already top? | 1616 1617 1618 //------------------------------Ideal------------------------------------------ 1619 // Return a node which is more "ideal" than the current node. Must preserve 1620 // the CFG, but we can still strip out dead paths. 1621 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1622 // The next should never happen after 6297035 fix. 1623 if( is_copy() ) // Already degraded to a Copy ? 1624 return NULL; // No change 1625 1626 Node *r = in(0); // RegionNode 1627 assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge"); 1628 1629 // Note: During parsing, phis are often transformed before their regions. 1630 // This means we have to use type_or_null to defend against untyped regions. 1631 if( phase->type_or_null(r) == Type::TOP ) // Dead code? 1632 return NULL; // No change 1633 1634 // If all inputs are value types, push the value type node down through the 1635 // phi because value type nodes should be merged through their input values. 1636 if (req() > 2 && in(1) && in(1)->is_ValueTypeBase()) { 1637 int opcode = in(1)->Opcode(); 1638 uint i = 2; 1639 for (; i < req() && in(i) && in(i)->is_ValueTypeBase(); i++) { 1640 assert(in(i)->Opcode() == opcode, "mixing pointers and values?"); 1641 } 1642 if (i == req()) { 1643 ValueTypeBaseNode* vt = in(1)->as_ValueTypeBase()->clone_with_phis(phase, in(0)); 1644 for (uint i = 2; i < req(); ++i) { 1645 vt->merge_with(phase, in(i)->as_ValueType(), i, i == (req()-1)); 1646 } 1647 return vt; 1648 } 1649 } 1650 1651 Node *top = phase->C->top(); 1652 bool new_phi = (outcnt() == 0); // transforming new Phi 1653 // No change for igvn if new phi is not hooked 1654 if (new_phi && can_reshape) 1655 return NULL; 1656 1657 // The are 2 situations when only one valid phi's input is left 1658 // (in addition to Region input). 1659 // One: region is not loop - replace phi with this input. 1660 // Two: region is loop - replace phi with top since this data path is dead 1661 // and we need to break the dead data loop. 1662 Node* progress = NULL; // Record if any progress made 1663 for( uint j = 1; j < req(); ++j ){ // For all paths in 1664 // Check unreachable control paths 1665 Node* rc = r->in(j); 1666 Node* n = in(j); // Get the input 1667 if (rc == NULL || phase->type(rc) == Type::TOP) { 1668 if (n != top) { // Not already top? |