src/share/vm/opto/cfgnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6889300 Sdiff src/share/vm/opto

src/share/vm/opto/cfgnode.cpp

Print this page




1514 }
1515 
1516 
1517 //------------------------------Ideal------------------------------------------
1518 // Return a node which is more "ideal" than the current node.  Must preserve
1519 // the CFG, but we can still strip out dead paths.
1520 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1521   // The next should never happen after 6297035 fix.
1522   if( is_copy() )               // Already degraded to a Copy ?
1523     return NULL;                // No change
1524 
1525   Node *r = in(0);              // RegionNode
1526   assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1527 
1528   // Note: During parsing, phis are often transformed before their regions.
1529   // This means we have to use type_or_null to defend against untyped regions.
1530   if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1531     return NULL;                // No change
1532 
1533   Node *top = phase->C->top();


1534 
1535   // The are 2 situations when only one valid phi's input is left
1536   // (in addition to Region input).
1537   // One: region is not loop - replace phi with this input.
1538   // Two: region is loop - replace phi with top since this data path is dead
1539   //                       and we need to break the dead data loop.
1540   Node* progress = NULL;        // Record if any progress made
1541   for( uint j = 1; j < req(); ++j ){ // For all paths in
1542     // Check unreachable control paths
1543     Node* rc = r->in(j);
1544     Node* n = in(j);            // Get the input
1545     if (rc == NULL || phase->type(rc) == Type::TOP) {
1546       if (n != top) {           // Not already top?
1547         set_req(j, top);        // Nuke it down
1548         progress = this;        // Record progress
1549       }
1550     }
1551   }
1552 






1553   Node* uin = unique_input(phase);
1554   if (uin == top) {             // Simplest case: no alive inputs.
1555     if (can_reshape)            // IGVN transformation
1556       return top;
1557     else
1558       return NULL;              // Identity will return TOP
1559   } else if (uin != NULL) {
1560     // Only one not-NULL unique input path is left.
1561     // Determine if this input is backedge of a loop.
1562     // (Skip new phis which have no uses and dead regions).
1563     if( outcnt() > 0 && r->in(0) != NULL ) {
1564       // First, take the short cut when we know it is a loop and
1565       // the EntryControl data path is dead.
1566       assert(!r->is_Loop() || r->req() == 3, "Loop node should have 3 inputs");
1567       // Then, check if there is a data loop when phi references itself directly
1568       // or through other data nodes.
1569       if( r->is_Loop() && !phase->eqv_uncast(uin, in(LoopNode::EntryControl)) ||
1570          !r->is_Loop() && is_unsafe_data_reference(uin) ) {
1571         // Break this data loop to avoid creation of a dead loop.
1572         if (can_reshape) {


1667     // This restriction is temporarily necessary to ensure termination:
1668     if (!saw_self && adr_type() == TypePtr::BOTTOM)  merge_width = 0;
1669 
1670     if (merge_width > Compile::AliasIdxRaw) {
1671       // found at least one non-empty MergeMem
1672       const TypePtr* at = adr_type();
1673       if (at != TypePtr::BOTTOM) {
1674         // Patch the existing phi to select an input from the merge:
1675         // Phi:AT1(...MergeMem(m0, m1, m2)...) into
1676         //     Phi:AT1(...m1...)
1677         int alias_idx = phase->C->get_alias_index(at);
1678         for (uint i=1; i<req(); ++i) {
1679           Node *ii = in(i);
1680           if (ii->is_MergeMem()) {
1681             MergeMemNode* n = ii->as_MergeMem();
1682             // compress paths and change unreachable cycles to TOP
1683             // If not, we can update the input infinitely along a MergeMem cycle
1684             // Equivalent code is in MemNode::Ideal_common
1685             Node *m  = phase->transform(n);
1686             if (outcnt() == 0) {  // Above transform() may kill us!
1687               progress = phase->C->top();
1688               break;
1689             }
1690             // If transformed to a MergeMem, get the desired slice
1691             // Otherwise the returned node represents memory for every slice
1692             Node *new_mem = (m->is_MergeMem()) ?
1693                              m->as_MergeMem()->memory_at(alias_idx) : m;
1694             // Update input if it is progress over what we have now
1695             if (new_mem != ii) {
1696               set_req(i, new_mem);
1697               progress = this;
1698             }
1699           }
1700         }
1701       } else {
1702         // We know that at least one MergeMem->base_memory() == this
1703         // (saw_self == true). If all other inputs also references this phi
1704         // (directly or through data nodes) - it is dead loop.
1705         bool saw_safe_input = false;
1706         for (uint j = 1; j < req(); ++j) {
1707           Node *n = in(j);
1708           if (n->is_MergeMem() && n->as_MergeMem()->base_memory() == this)




1514 }
1515 
1516 
1517 //------------------------------Ideal------------------------------------------
1518 // Return a node which is more "ideal" than the current node.  Must preserve
1519 // the CFG, but we can still strip out dead paths.
1520 Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1521   // The next should never happen after 6297035 fix.
1522   if( is_copy() )               // Already degraded to a Copy ?
1523     return NULL;                // No change
1524 
1525   Node *r = in(0);              // RegionNode
1526   assert(r->in(0) == NULL || !r->in(0)->is_Root(), "not a specially hidden merge");
1527 
1528   // Note: During parsing, phis are often transformed before their regions.
1529   // This means we have to use type_or_null to defend against untyped regions.
1530   if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1531     return NULL;                // No change
1532 
1533   Node *top = phase->C->top();
1534   bool new_phi = (outcnt() == 0); // transforming new Phi
1535   assert(!can_reshape || !new_phi, "for igvn new phi should be hooked");
1536 
1537   // The are 2 situations when only one valid phi's input is left
1538   // (in addition to Region input).
1539   // One: region is not loop - replace phi with this input.
1540   // Two: region is loop - replace phi with top since this data path is dead
1541   //                       and we need to break the dead data loop.
1542   Node* progress = NULL;        // Record if any progress made
1543   for( uint j = 1; j < req(); ++j ){ // For all paths in
1544     // Check unreachable control paths
1545     Node* rc = r->in(j);
1546     Node* n = in(j);            // Get the input
1547     if (rc == NULL || phase->type(rc) == Type::TOP) {
1548       if (n != top) {           // Not already top?
1549         set_req(j, top);        // Nuke it down
1550         progress = this;        // Record progress
1551       }
1552     }
1553   }
1554 
1555   if (can_reshape && outcnt() == 0) {
1556     // set_req() above may kill outputs if Phi is referenced
1557     // only by itself on the dead (top) control path.
1558     return top;
1559   }
1560 
1561   Node* uin = unique_input(phase);
1562   if (uin == top) {             // Simplest case: no alive inputs.
1563     if (can_reshape)            // IGVN transformation
1564       return top;
1565     else
1566       return NULL;              // Identity will return TOP
1567   } else if (uin != NULL) {
1568     // Only one not-NULL unique input path is left.
1569     // Determine if this input is backedge of a loop.
1570     // (Skip new phis which have no uses and dead regions).
1571     if( outcnt() > 0 && r->in(0) != NULL ) {
1572       // First, take the short cut when we know it is a loop and
1573       // the EntryControl data path is dead.
1574       assert(!r->is_Loop() || r->req() == 3, "Loop node should have 3 inputs");
1575       // Then, check if there is a data loop when phi references itself directly
1576       // or through other data nodes.
1577       if( r->is_Loop() && !phase->eqv_uncast(uin, in(LoopNode::EntryControl)) ||
1578          !r->is_Loop() && is_unsafe_data_reference(uin) ) {
1579         // Break this data loop to avoid creation of a dead loop.
1580         if (can_reshape) {


1675     // This restriction is temporarily necessary to ensure termination:
1676     if (!saw_self && adr_type() == TypePtr::BOTTOM)  merge_width = 0;
1677 
1678     if (merge_width > Compile::AliasIdxRaw) {
1679       // found at least one non-empty MergeMem
1680       const TypePtr* at = adr_type();
1681       if (at != TypePtr::BOTTOM) {
1682         // Patch the existing phi to select an input from the merge:
1683         // Phi:AT1(...MergeMem(m0, m1, m2)...) into
1684         //     Phi:AT1(...m1...)
1685         int alias_idx = phase->C->get_alias_index(at);
1686         for (uint i=1; i<req(); ++i) {
1687           Node *ii = in(i);
1688           if (ii->is_MergeMem()) {
1689             MergeMemNode* n = ii->as_MergeMem();
1690             // compress paths and change unreachable cycles to TOP
1691             // If not, we can update the input infinitely along a MergeMem cycle
1692             // Equivalent code is in MemNode::Ideal_common
1693             Node *m  = phase->transform(n);
1694             if (outcnt() == 0) {  // Above transform() may kill us!
1695               return top;

1696             }
1697             // If transformed to a MergeMem, get the desired slice
1698             // Otherwise the returned node represents memory for every slice
1699             Node *new_mem = (m->is_MergeMem()) ?
1700                              m->as_MergeMem()->memory_at(alias_idx) : m;
1701             // Update input if it is progress over what we have now
1702             if (new_mem != ii) {
1703               set_req(i, new_mem);
1704               progress = this;
1705             }
1706           }
1707         }
1708       } else {
1709         // We know that at least one MergeMem->base_memory() == this
1710         // (saw_self == true). If all other inputs also references this phi
1711         // (directly or through data nodes) - it is dead loop.
1712         bool saw_safe_input = false;
1713         for (uint j = 1; j < req(); ++j) {
1714           Node *n = in(j);
1715           if (n->is_MergeMem() && n->as_MergeMem()->base_memory() == this)


src/share/vm/opto/cfgnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File