1608 1609 //------------------------------Identity--------------------------------------- 1610 // If the test is constant & we match, then we are the input Control 1611 Node *IfProjNode::Identity(PhaseTransform *phase) { 1612 // Can only optimize if cannot go the other way 1613 const TypeTuple *t = phase->type(in(0))->is_tuple(); 1614 if (t == TypeTuple::IFNEITHER || 1615 // kill dead branch first otherwise the IfNode's control will 1616 // have 2 control uses (the IfNode that doesn't go away because 1617 // it still has uses and this branch of the 1618 // If). Node::has_special_unique_user() will cause this node to 1619 // be reprocessed once the dead branch is killed. 1620 (always_taken(t) && in(0)->outcnt() == 1)) { 1621 // IfNode control 1622 return in(0)->in(0); 1623 } 1624 // no progress 1625 return this; 1626 } 1627 1628 #ifndef PRODUCT 1629 //-------------------------------related--------------------------------------- 1630 // An IfProjNode's related node set consists of its input (an IfNode) including 1631 // the IfNode's condition, plus all of its outputs at level 1. In compact mode, 1632 // the restrictions for IfNode apply (see IfNode::rel). 1633 void IfProjNode::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { 1634 Node* ifNode = this->in(0); 1635 in_rel->append(ifNode); 1636 if (compact) { 1637 ifNode->collect_nodes(in_rel, 3, false, true); 1638 } else { 1639 ifNode->collect_nodes_in_all_data(in_rel, false); 1640 } 1641 this->collect_nodes(out_rel, -1, false, false); 1642 } 1643 1644 //------------------------------dump_spec-------------------------------------- 1645 void IfNode::dump_spec(outputStream *st) const { 1646 st->print("P=%f, C=%f",_prob,_fcnt); 1647 } | 1608 1609 //------------------------------Identity--------------------------------------- 1610 // If the test is constant & we match, then we are the input Control 1611 Node *IfProjNode::Identity(PhaseTransform *phase) { 1612 // Can only optimize if cannot go the other way 1613 const TypeTuple *t = phase->type(in(0))->is_tuple(); 1614 if (t == TypeTuple::IFNEITHER || 1615 // kill dead branch first otherwise the IfNode's control will 1616 // have 2 control uses (the IfNode that doesn't go away because 1617 // it still has uses and this branch of the 1618 // If). Node::has_special_unique_user() will cause this node to 1619 // be reprocessed once the dead branch is killed. 1620 (always_taken(t) && in(0)->outcnt() == 1)) { 1621 // IfNode control 1622 return in(0)->in(0); 1623 } 1624 // no progress 1625 return this; 1626 } 1627 1628 Node* IfProjNode::Ideal(PhaseGVN* phase, bool can_reshape) { 1629 if (in(0)->is_top()) { 1630 return NULL; 1631 } 1632 const TypeTuple* t = phase->type(in(0))->is_tuple(); 1633 if (never_taken(t)) { 1634 // Disconnect never taken branch 1635 set_req(0, phase->C->top()); 1636 return this; 1637 } 1638 return NULL; 1639 } 1640 1641 #ifndef PRODUCT 1642 //-------------------------------related--------------------------------------- 1643 // An IfProjNode's related node set consists of its input (an IfNode) including 1644 // the IfNode's condition, plus all of its outputs at level 1. In compact mode, 1645 // the restrictions for IfNode apply (see IfNode::rel). 1646 void IfProjNode::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { 1647 Node* ifNode = this->in(0); 1648 in_rel->append(ifNode); 1649 if (compact) { 1650 ifNode->collect_nodes(in_rel, 3, false, true); 1651 } else { 1652 ifNode->collect_nodes_in_all_data(in_rel, false); 1653 } 1654 this->collect_nodes(out_rel, -1, false, false); 1655 } 1656 1657 //------------------------------dump_spec-------------------------------------- 1658 void IfNode::dump_spec(outputStream *st) const { 1659 st->print("P=%f, C=%f",_prob,_fcnt); 1660 } |