1539
1540
1541 //------------------------------Ideal------------------------------------------
1542 // Return a node which is more "ideal" than the current node. Must preserve
1543 // the CFG, but we can still strip out dead paths.
1544 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1545 // The next should never happen after 6297035 fix.
1546 if( is_copy() ) // Already degraded to a Copy ?
1547 return NULL; // No change
1548
1549 Node *r = in(0); // RegionNode
1550 assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1551
1552 // Note: During parsing, phis are often transformed before their regions.
1553 // This means we have to use type_or_null to defend against untyped regions.
1554 if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1555 return NULL; // No change
1556
1557 Node *top = phase->C->top();
1558 bool new_phi = (outcnt() == 0); // transforming new Phi
1559 assert(!can_reshape || !new_phi, "for igvn new phi should be hooked");
1560
1561 // The are 2 situations when only one valid phi's input is left
1562 // (in addition to Region input).
1563 // One: region is not loop - replace phi with this input.
1564 // Two: region is loop - replace phi with top since this data path is dead
1565 // and we need to break the dead data loop.
1566 Node* progress = NULL; // Record if any progress made
1567 for( uint j = 1; j < req(); ++j ){ // For all paths in
1568 // Check unreachable control paths
1569 Node* rc = r->in(j);
1570 Node* n = in(j); // Get the input
1571 if (rc == NULL || phase->type(rc) == Type::TOP) {
1572 if (n != top) { // Not already top?
1573 set_req(j, top); // Nuke it down
1574 progress = this; // Record progress
1575 }
1576 }
1577 }
1578
1579 if (can_reshape && outcnt() == 0) {
|
1539
1540
1541 //------------------------------Ideal------------------------------------------
1542 // Return a node which is more "ideal" than the current node. Must preserve
1543 // the CFG, but we can still strip out dead paths.
1544 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1545 // The next should never happen after 6297035 fix.
1546 if( is_copy() ) // Already degraded to a Copy ?
1547 return NULL; // No change
1548
1549 Node *r = in(0); // RegionNode
1550 assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1551
1552 // Note: During parsing, phis are often transformed before their regions.
1553 // This means we have to use type_or_null to defend against untyped regions.
1554 if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1555 return NULL; // No change
1556
1557 Node *top = phase->C->top();
1558 bool new_phi = (outcnt() == 0); // transforming new Phi
1559 // No change for igvn if new phi is not hooked
1560 if (new_phi && can_reshape)
1561 return NULL;
1562
1563 // The are 2 situations when only one valid phi's input is left
1564 // (in addition to Region input).
1565 // One: region is not loop - replace phi with this input.
1566 // Two: region is loop - replace phi with top since this data path is dead
1567 // and we need to break the dead data loop.
1568 Node* progress = NULL; // Record if any progress made
1569 for( uint j = 1; j < req(); ++j ){ // For all paths in
1570 // Check unreachable control paths
1571 Node* rc = r->in(j);
1572 Node* n = in(j); // Get the input
1573 if (rc == NULL || phase->type(rc) == Type::TOP) {
1574 if (n != top) { // Not already top?
1575 set_req(j, top); // Nuke it down
1576 progress = this; // Record progress
1577 }
1578 }
1579 }
1580
1581 if (can_reshape && outcnt() == 0) {
|