< prev index next >

src/hotspot/share/opto/cfgnode.cpp

Print this page




1629   return false; // The phi is not reachable from its inputs
1630 }
1631 
1632 
1633 //------------------------------Ideal------------------------------------------
1634 // Return a node which is more "ideal" than the current node.  Must preserve
1635 // the CFG, but we can still strip out dead paths.
1636 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1637   // The next should never happen after 6297035 fix.
1638   if( is_copy() )               // Already degraded to a Copy ?
1639     return NULL;                // No change
1640 
1641   Node *r = in(0);              // RegionNode
1642   assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1643 
1644   // Note: During parsing, phis are often transformed before their regions.
1645   // This means we have to use type_or_null to defend against untyped regions.
1646   if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1647     return NULL;                // No change
1648 
1649   // If all inputs are value types, push the value type node down through the
1650   // phi because value type nodes should be merged through their input values.
1651   if (req() > 2 && in(1) != NULL && in(1)->is_ValueTypeBase() && (can_reshape || in(1)->is_ValueType())) {
1652     int opcode = in(1)->Opcode();
1653     uint i = 2;
1654     for (; i < req() && in(i) && in(i)->is_ValueTypeBase(); i++) {

1655       assert(in(i)->Opcode() == opcode, "mixing pointers and values?");
1656     }
1657     if (i == req()) {
1658       ValueTypeBaseNode* vt = in(1)->as_ValueTypeBase()->clone_with_phis(phase, in(0));
1659       for (uint i = 2; i < req(); ++i) {
1660         vt->merge_with(phase, in(i)->as_ValueTypeBase(), i, i == (req()-1));
1661       }
1662       return vt;
1663     }
1664   }
1665 
1666   if (type()->is_valuetypeptr() && can_reshape) {
1667     // If the Phi merges the result from a mix of constant and non
1668     // constant method handles, only some of its inputs are
1669     // ValueTypePtr nodes and we can't push the ValueTypePtr node down
1670     // to remove the need for allocations. This if fixed by transforming:
1671     //
1672     // (Phi ValueTypePtr#1 Node#2) to (Phi ValueTypePtr#1 CheckCastPP#2)
1673     //
1674     // Then pushing the CheckCastPP up through Phis until it reaches




1629   return false; // The phi is not reachable from its inputs
1630 }
1631 
1632 
1633 //------------------------------Ideal------------------------------------------
1634 // Return a node which is more "ideal" than the current node.  Must preserve
1635 // the CFG, but we can still strip out dead paths.
1636 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1637   // The next should never happen after 6297035 fix.
1638   if( is_copy() )               // Already degraded to a Copy ?
1639     return NULL;                // No change
1640 
1641   Node *r = in(0);              // RegionNode
1642   assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1643 
1644   // Note: During parsing, phis are often transformed before their regions.
1645   // This means we have to use type_or_null to defend against untyped regions.
1646   if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1647     return NULL;                // No change
1648 
1649   // If all inputs are value types of the same type, push the value type node down
1650   // through the phi because value type nodes should be merged through their input values.
1651   if (req() > 2 && in(1) != NULL && in(1)->is_ValueTypeBase() && (can_reshape || in(1)->is_ValueType())) {
1652     int opcode = in(1)->Opcode();
1653     uint i = 2;
1654     // Check if inputs are values of the same type
1655     for (; i < req() && in(i) && in(i)->is_ValueTypeBase() && in(i)->cmp(*in(1)); i++) {
1656       assert(in(i)->Opcode() == opcode, "mixing pointers and values?");
1657     }
1658     if (i == req()) {
1659       ValueTypeBaseNode* vt = in(1)->as_ValueTypeBase()->clone_with_phis(phase, in(0));
1660       for (uint i = 2; i < req(); ++i) {
1661         vt->merge_with(phase, in(i)->as_ValueTypeBase(), i, i == (req()-1));
1662       }
1663       return vt;
1664     }
1665   }
1666 
1667   if (type()->is_valuetypeptr() && can_reshape) {
1668     // If the Phi merges the result from a mix of constant and non
1669     // constant method handles, only some of its inputs are
1670     // ValueTypePtr nodes and we can't push the ValueTypePtr node down
1671     // to remove the need for allocations. This if fixed by transforming:
1672     //
1673     // (Phi ValueTypePtr#1 Node#2) to (Phi ValueTypePtr#1 CheckCastPP#2)
1674     //
1675     // Then pushing the CheckCastPP up through Phis until it reaches


< prev index next >