1593 // We can't return top if we are in Parse phase - cut inputs only
1594 // to stop further optimizations for this phi. Identity will return TOP.
1595 assert(req() == 3, "only diamond merge phi here");
1596 set_req(1, top);
1597 set_req(2, top);
1598 return NULL;
1599 } else {
1600 return opt;
1601 }
1602 }
1603 }
1604
1605 // Check for merging identical values and split flow paths
1606 if (can_reshape) {
1607 opt = split_flow_path(phase, this);
1608 // This optimization only modifies phi - don't need to check for dead loop.
1609 assert(opt == NULL || phase->eqv(opt, this), "do not elide phi");
1610 if (opt != NULL) return opt;
1611 }
1612
1613 if (in(1) != NULL && in(1)->Opcode() == Op_AddP && can_reshape) {
1614 // Try to undo Phi of AddP:
1615 // (Phi (AddP base base y) (AddP base2 base2 y))
1616 // becomes:
1617 // newbase := (Phi base base2)
1618 // (AddP newbase newbase y)
1619 //
1620 // This occurs as a result of unsuccessful split_thru_phi and
1621 // interferes with taking advantage of addressing modes. See the
1622 // clone_shift_expressions code in matcher.cpp
1623 Node* addp = in(1);
1624 const Type* type = addp->in(AddPNode::Base)->bottom_type();
1625 Node* y = addp->in(AddPNode::Offset);
1626 if (y != NULL && addp->in(AddPNode::Base) == addp->in(AddPNode::Address)) {
1627 // make sure that all the inputs are similar to the first one,
1628 // i.e. AddP with base == address and same offset as first AddP
1629 bool doit = true;
1630 for (uint i = 2; i < req(); i++) {
1631 if (in(i) == NULL ||
1632 in(i)->Opcode() != Op_AddP ||
1633 in(i)->in(AddPNode::Base) != in(i)->in(AddPNode::Address) ||
1634 in(i)->in(AddPNode::Offset) != y) {
1635 doit = false;
1636 break;
1637 }
1638 // Accumulate type for resulting Phi
1639 type = type->meet(in(i)->in(AddPNode::Base)->bottom_type());
1640 }
1641 Node* base = NULL;
1642 if (doit) {
1643 // Check for neighboring AddP nodes in a tree.
1644 // If they have a base, use that it.
1645 for (DUIterator_Fast kmax, k = this->fast_outs(kmax); k < kmax; k++) {
1646 Node* u = this->fast_out(k);
1647 if (u->is_AddP()) {
1648 Node* base2 = u->in(AddPNode::Base);
1649 if (base2 != NULL && !base2->is_top()) {
1650 if (base == NULL)
1651 base = base2;
1652 else if (base != base2)
1653 { doit = false; break; }
1654 }
1655 }
1656 }
1657 }
1658 if (doit) {
1659 if (base == NULL) {
1660 base = new (phase->C, in(0)->req()) PhiNode(in(0), type, NULL);
1661 for (uint i = 1; i < req(); i++) {
1662 base->init_req(i, in(i)->in(AddPNode::Base));
1663 }
1664 phase->is_IterGVN()->register_new_node_with_optimizer(base);
1665 }
1666 return new (phase->C, 4) AddPNode(base, base, y);
1667 }
1668 }
1669 }
1670
1671 // Split phis through memory merges, so that the memory merges will go away.
1672 // Piggy-back this transformation on the search for a unique input....
1673 // It will be as if the merged memory is the unique value of the phi.
1674 // (Do not attempt this optimization unless parsing is complete.
1675 // It would make the parser's memory-merge logic sick.)
1676 // (MergeMemNode is not dead_loop_safe - need to check for dead loop.)
1677 if (progress == NULL && can_reshape && type() == Type::MEMORY) {
1678 // see if this phi should be sliced
1679 uint merge_width = 0;
1680 bool saw_self = false;
1681 for( uint i=1; i<req(); ++i ) {// For all paths in
1682 Node *ii = in(i);
1683 if (ii->is_MergeMem()) {
1684 MergeMemNode* n = ii->as_MergeMem();
1685 merge_width = MAX2(merge_width, n->req());
1686 saw_self = saw_self || phase->eqv(n->base_memory(), this);
1687 }
1688 }
1689
1690 // This restriction is temporarily necessary to ensure termination:
|
1593 // We can't return top if we are in Parse phase - cut inputs only
1594 // to stop further optimizations for this phi. Identity will return TOP.
1595 assert(req() == 3, "only diamond merge phi here");
1596 set_req(1, top);
1597 set_req(2, top);
1598 return NULL;
1599 } else {
1600 return opt;
1601 }
1602 }
1603 }
1604
1605 // Check for merging identical values and split flow paths
1606 if (can_reshape) {
1607 opt = split_flow_path(phase, this);
1608 // This optimization only modifies phi - don't need to check for dead loop.
1609 assert(opt == NULL || phase->eqv(opt, this), "do not elide phi");
1610 if (opt != NULL) return opt;
1611 }
1612
1613 // Split phis through memory merges, so that the memory merges will go away.
1614 // Piggy-back this transformation on the search for a unique input....
1615 // It will be as if the merged memory is the unique value of the phi.
1616 // (Do not attempt this optimization unless parsing is complete.
1617 // It would make the parser's memory-merge logic sick.)
1618 // (MergeMemNode is not dead_loop_safe - need to check for dead loop.)
1619 if (progress == NULL && can_reshape && type() == Type::MEMORY) {
1620 // see if this phi should be sliced
1621 uint merge_width = 0;
1622 bool saw_self = false;
1623 for( uint i=1; i<req(); ++i ) {// For all paths in
1624 Node *ii = in(i);
1625 if (ii->is_MergeMem()) {
1626 MergeMemNode* n = ii->as_MergeMem();
1627 merge_width = MAX2(merge_width, n->req());
1628 saw_self = saw_self || phase->eqv(n->base_memory(), this);
1629 }
1630 }
1631
1632 // This restriction is temporarily necessary to ensure termination:
|