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 const Type* t = phase->type(in(0)); 1630 if (in(0)->outcnt() == 2 && t != Type::TOP && always_taken(t->is_tuple())) { 1631 // cut off dead branch if this branch is always taken 1632 Node* other = in(0)->as_If()->proj_out(!is_IfTrue()); 1633 other->set_req(0, phase->C->top()); 1634 return this; 1635 } 1636 return NULL; 1637 } 1638 1639 #ifndef PRODUCT 1640 //-------------------------------related--------------------------------------- 1641 // An IfProjNode's related node set consists of its input (an IfNode) including 1642 // the IfNode's condition, plus all of its outputs at level 1. In compact mode, 1643 // the restrictions for IfNode apply (see IfNode::rel). 1644 void IfProjNode::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { 1645 Node* ifNode = this->in(0); 1646 in_rel->append(ifNode); 1647 if (compact) { 1648 ifNode->collect_nodes(in_rel, 3, false, true); 1649 } else { 1650 ifNode->collect_nodes_in_all_data(in_rel, false); 1651 } 1652 this->collect_nodes(out_rel, -1, false, false); 1653 } 1654 1655 //------------------------------dump_spec-------------------------------------- 1656 void IfNode::dump_spec(outputStream *st) const { 1657 st->print("P=%f, C=%f",_prob,_fcnt); 1658 } |