Mercurial > hg > truffle
comparison src/share/vm/opto/cfgnode.cpp @ 1542:eb79484f795f
6937111: Restore optimization for Phi of AddP (6552204)
Summary: Restored the original code which was removed by the fix for 6614100.
Reviewed-by: never
author | kvn |
---|---|
date | Mon, 05 Apr 2010 10:17:15 -0700 |
parents | ce590301ae2a |
children | 1a1603f975b5 |
comparison
equal
deleted
inserted
replaced
1351:9bb91718aaf2 | 1542:eb79484f795f |
---|---|
1651 // This optimization only modifies phi - don't need to check for dead loop. | 1651 // This optimization only modifies phi - don't need to check for dead loop. |
1652 assert(opt == NULL || phase->eqv(opt, this), "do not elide phi"); | 1652 assert(opt == NULL || phase->eqv(opt, this), "do not elide phi"); |
1653 if (opt != NULL) return opt; | 1653 if (opt != NULL) return opt; |
1654 } | 1654 } |
1655 | 1655 |
1656 if (in(1) != NULL && in(1)->Opcode() == Op_AddP && can_reshape) { | |
1657 // Try to undo Phi of AddP: | |
1658 // (Phi (AddP base base y) (AddP base2 base2 y)) | |
1659 // becomes: | |
1660 // newbase := (Phi base base2) | |
1661 // (AddP newbase newbase y) | |
1662 // | |
1663 // This occurs as a result of unsuccessful split_thru_phi and | |
1664 // interferes with taking advantage of addressing modes. See the | |
1665 // clone_shift_expressions code in matcher.cpp | |
1666 Node* addp = in(1); | |
1667 const Type* type = addp->in(AddPNode::Base)->bottom_type(); | |
1668 Node* y = addp->in(AddPNode::Offset); | |
1669 if (y != NULL && addp->in(AddPNode::Base) == addp->in(AddPNode::Address)) { | |
1670 // make sure that all the inputs are similar to the first one, | |
1671 // i.e. AddP with base == address and same offset as first AddP | |
1672 bool doit = true; | |
1673 for (uint i = 2; i < req(); i++) { | |
1674 if (in(i) == NULL || | |
1675 in(i)->Opcode() != Op_AddP || | |
1676 in(i)->in(AddPNode::Base) != in(i)->in(AddPNode::Address) || | |
1677 in(i)->in(AddPNode::Offset) != y) { | |
1678 doit = false; | |
1679 break; | |
1680 } | |
1681 // Accumulate type for resulting Phi | |
1682 type = type->meet(in(i)->in(AddPNode::Base)->bottom_type()); | |
1683 } | |
1684 Node* base = NULL; | |
1685 if (doit) { | |
1686 // Check for neighboring AddP nodes in a tree. | |
1687 // If they have a base, use that it. | |
1688 for (DUIterator_Fast kmax, k = this->fast_outs(kmax); k < kmax; k++) { | |
1689 Node* u = this->fast_out(k); | |
1690 if (u->is_AddP()) { | |
1691 Node* base2 = u->in(AddPNode::Base); | |
1692 if (base2 != NULL && !base2->is_top()) { | |
1693 if (base == NULL) | |
1694 base = base2; | |
1695 else if (base != base2) | |
1696 { doit = false; break; } | |
1697 } | |
1698 } | |
1699 } | |
1700 } | |
1701 if (doit) { | |
1702 if (base == NULL) { | |
1703 base = new (phase->C, in(0)->req()) PhiNode(in(0), type, NULL); | |
1704 for (uint i = 1; i < req(); i++) { | |
1705 base->init_req(i, in(i)->in(AddPNode::Base)); | |
1706 } | |
1707 phase->is_IterGVN()->register_new_node_with_optimizer(base); | |
1708 } | |
1709 return new (phase->C, 4) AddPNode(base, base, y); | |
1710 } | |
1711 } | |
1712 } | |
1713 | |
1656 // Split phis through memory merges, so that the memory merges will go away. | 1714 // Split phis through memory merges, so that the memory merges will go away. |
1657 // Piggy-back this transformation on the search for a unique input.... | 1715 // Piggy-back this transformation on the search for a unique input.... |
1658 // It will be as if the merged memory is the unique value of the phi. | 1716 // It will be as if the merged memory is the unique value of the phi. |
1659 // (Do not attempt this optimization unless parsing is complete. | 1717 // (Do not attempt this optimization unless parsing is complete. |
1660 // It would make the parser's memory-merge logic sick.) | 1718 // It would make the parser's memory-merge logic sick.) |