Mercurial > hg > truffle
comparison src/share/vm/opto/loopnode.cpp @ 921:046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
Reviewed-by: kvn, twisti
author | never |
---|---|
date | Fri, 14 Aug 2009 00:02:12 -0700 |
parents | fbde8ec322d0 |
children | 8b22f86d1740 |
comparison
equal
deleted
inserted
replaced
910:10d8c0d0d60e | 921:046932b72aa2 |
---|---|
1418 if( loop->_next ) log_loop_tree(root, loop->_next, log); | 1418 if( loop->_next ) log_loop_tree(root, loop->_next, log); |
1419 } | 1419 } |
1420 } | 1420 } |
1421 | 1421 |
1422 //============================================================================= | 1422 //============================================================================= |
1423 //------------------------------PhaseIdealLoop--------------------------------- | 1423 //----------------------------build_and_optimize------------------------------- |
1424 // Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to | 1424 // Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to |
1425 // its corresponding LoopNode. If 'optimize' is true, do some loop cleanups. | 1425 // its corresponding LoopNode. If 'optimize' is true, do some loop cleanups. |
1426 PhaseIdealLoop::PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify_me, bool do_split_ifs ) | 1426 void PhaseIdealLoop::build_and_optimize(bool do_split_ifs) { |
1427 : PhaseTransform(Ideal_Loop), | 1427 int old_progress = C->major_progress(); |
1428 _igvn(igvn), | 1428 |
1429 _dom_lca_tags(C->comp_arena()) { | |
1430 // Reset major-progress flag for the driver's heuristics | 1429 // Reset major-progress flag for the driver's heuristics |
1431 C->clear_major_progress(); | 1430 C->clear_major_progress(); |
1432 | 1431 |
1433 #ifndef PRODUCT | 1432 #ifndef PRODUCT |
1434 // Capture for later assert | 1433 // Capture for later assert |
1463 if (C->failing()) { | 1462 if (C->failing()) { |
1464 return; | 1463 return; |
1465 } | 1464 } |
1466 | 1465 |
1467 // No loops after all | 1466 // No loops after all |
1468 if( !_ltree_root->_child ) C->set_has_loops(false); | 1467 if( !_ltree_root->_child && !_verify_only ) C->set_has_loops(false); |
1469 | 1468 |
1470 // There should always be an outer loop containing the Root and Return nodes. | 1469 // There should always be an outer loop containing the Root and Return nodes. |
1471 // If not, we have a degenerate empty program. Bail out in this case. | 1470 // If not, we have a degenerate empty program. Bail out in this case. |
1472 if (!has_node(C->root())) { | 1471 if (!has_node(C->root())) { |
1473 C->clear_major_progress(); | 1472 if (!_verify_only) { |
1474 C->record_method_not_compilable("empty program detected during loop optimization"); | 1473 C->clear_major_progress(); |
1474 C->record_method_not_compilable("empty program detected during loop optimization"); | |
1475 } | |
1475 return; | 1476 return; |
1476 } | 1477 } |
1477 | 1478 |
1478 // Nothing to do, so get out | 1479 // Nothing to do, so get out |
1479 if( !C->has_loops() && !do_split_ifs && !verify_me) { | 1480 if( !C->has_loops() && !do_split_ifs && !_verify_me && !_verify_only ) { |
1480 _igvn.optimize(); // Cleanup NeverBranches | 1481 _igvn.optimize(); // Cleanup NeverBranches |
1481 return; | 1482 return; |
1482 } | 1483 } |
1483 | 1484 |
1484 // Set loop nesting depth | 1485 // Set loop nesting depth |
1485 _ltree_root->set_nest( 0 ); | 1486 _ltree_root->set_nest( 0 ); |
1486 | 1487 |
1487 // Split shared headers and insert loop landing pads. | 1488 // Split shared headers and insert loop landing pads. |
1488 // Do not bother doing this on the Root loop of course. | 1489 // Do not bother doing this on the Root loop of course. |
1489 if( !verify_me && _ltree_root->_child ) { | 1490 if( !_verify_me && !_verify_only && _ltree_root->_child ) { |
1490 if( _ltree_root->_child->beautify_loops( this ) ) { | 1491 if( _ltree_root->_child->beautify_loops( this ) ) { |
1491 // Re-build loop tree! | 1492 // Re-build loop tree! |
1492 _ltree_root->_child = NULL; | 1493 _ltree_root->_child = NULL; |
1493 _nodes.clear(); | 1494 _nodes.clear(); |
1494 reallocate_preorders(); | 1495 reallocate_preorders(); |
1513 _dom_stk = NULL; // Allocated on demand in recompute_dom_depth | 1514 _dom_stk = NULL; // Allocated on demand in recompute_dom_depth |
1514 memset( _dom_depth, 0, _idom_size * sizeof(uint) ); | 1515 memset( _dom_depth, 0, _idom_size * sizeof(uint) ); |
1515 | 1516 |
1516 Dominators(); | 1517 Dominators(); |
1517 | 1518 |
1518 // As a side effect, Dominators removed any unreachable CFG paths | 1519 if (!_verify_only) { |
1519 // into RegionNodes. It doesn't do this test against Root, so | 1520 // As a side effect, Dominators removed any unreachable CFG paths |
1520 // we do it here. | 1521 // into RegionNodes. It doesn't do this test against Root, so |
1521 for( uint i = 1; i < C->root()->req(); i++ ) { | 1522 // we do it here. |
1522 if( !_nodes[C->root()->in(i)->_idx] ) { // Dead path into Root? | 1523 for( uint i = 1; i < C->root()->req(); i++ ) { |
1523 _igvn.hash_delete(C->root()); | 1524 if( !_nodes[C->root()->in(i)->_idx] ) { // Dead path into Root? |
1524 C->root()->del_req(i); | 1525 _igvn.hash_delete(C->root()); |
1525 _igvn._worklist.push(C->root()); | 1526 C->root()->del_req(i); |
1526 i--; // Rerun same iteration on compressed edges | 1527 _igvn._worklist.push(C->root()); |
1527 } | 1528 i--; // Rerun same iteration on compressed edges |
1528 } | 1529 } |
1529 | 1530 } |
1530 // Given dominators, try to find inner loops with calls that must | 1531 |
1531 // always be executed (call dominates loop tail). These loops do | 1532 // Given dominators, try to find inner loops with calls that must |
1532 // not need a separate safepoint. | 1533 // always be executed (call dominates loop tail). These loops do |
1533 Node_List cisstack(a); | 1534 // not need a separate safepoint. |
1534 _ltree_root->check_safepts(visited, cisstack); | 1535 Node_List cisstack(a); |
1536 _ltree_root->check_safepts(visited, cisstack); | |
1537 } | |
1535 | 1538 |
1536 // Walk the DATA nodes and place into loops. Find earliest control | 1539 // Walk the DATA nodes and place into loops. Find earliest control |
1537 // node. For CFG nodes, the _nodes array starts out and remains | 1540 // node. For CFG nodes, the _nodes array starts out and remains |
1538 // holding the associated IdealLoopTree pointer. For DATA nodes, the | 1541 // holding the associated IdealLoopTree pointer. For DATA nodes, the |
1539 // _nodes array holds the earliest legal controlling CFG node. | 1542 // _nodes array holds the earliest legal controlling CFG node. |
1546 Node_List worklist(a); | 1549 Node_List worklist(a); |
1547 // Don't need C->root() on worklist since | 1550 // Don't need C->root() on worklist since |
1548 // it will be processed among C->top() inputs | 1551 // it will be processed among C->top() inputs |
1549 worklist.push( C->top() ); | 1552 worklist.push( C->top() ); |
1550 visited.set( C->top()->_idx ); // Set C->top() as visited now | 1553 visited.set( C->top()->_idx ); // Set C->top() as visited now |
1551 build_loop_early( visited, worklist, nstack, verify_me ); | 1554 build_loop_early( visited, worklist, nstack ); |
1552 | 1555 |
1553 // Given early legal placement, try finding counted loops. This placement | 1556 // Given early legal placement, try finding counted loops. This placement |
1554 // is good enough to discover most loop invariants. | 1557 // is good enough to discover most loop invariants. |
1555 if( !verify_me ) | 1558 if( !_verify_me && !_verify_only ) |
1556 _ltree_root->counted_loop( this ); | 1559 _ltree_root->counted_loop( this ); |
1557 | 1560 |
1558 // Find latest loop placement. Find ideal loop placement. | 1561 // Find latest loop placement. Find ideal loop placement. |
1559 visited.Clear(); | 1562 visited.Clear(); |
1560 init_dom_lca_tags(); | 1563 init_dom_lca_tags(); |
1561 // Need C->root() on worklist when processing outs | 1564 // Need C->root() on worklist when processing outs |
1562 worklist.push( C->root() ); | 1565 worklist.push( C->root() ); |
1563 NOT_PRODUCT( C->verify_graph_edges(); ) | 1566 NOT_PRODUCT( C->verify_graph_edges(); ) |
1564 worklist.push( C->top() ); | 1567 worklist.push( C->top() ); |
1565 build_loop_late( visited, worklist, nstack, verify_me ); | 1568 build_loop_late( visited, worklist, nstack ); |
1569 | |
1570 if (_verify_only) { | |
1571 // restore major progress flag | |
1572 for (int i = 0; i < old_progress; i++) | |
1573 C->set_major_progress(); | |
1574 assert(C->unique() == unique, "verification mode made Nodes? ? ?"); | |
1575 assert(_igvn._worklist.size() == 0, "shouldn't push anything"); | |
1576 return; | |
1577 } | |
1566 | 1578 |
1567 // clear out the dead code | 1579 // clear out the dead code |
1568 while(_deadlist.size()) { | 1580 while(_deadlist.size()) { |
1569 igvn.remove_globally_dead_node(_deadlist.pop()); | 1581 _igvn.remove_globally_dead_node(_deadlist.pop()); |
1570 } | 1582 } |
1571 | 1583 |
1572 #ifndef PRODUCT | 1584 #ifndef PRODUCT |
1573 C->verify_graph_edges(); | 1585 C->verify_graph_edges(); |
1574 if( verify_me ) { // Nested verify pass? | 1586 if( _verify_me ) { // Nested verify pass? |
1575 // Check to see if the verify mode is broken | 1587 // Check to see if the verify mode is broken |
1576 assert(C->unique() == unique, "non-optimize mode made Nodes? ? ?"); | 1588 assert(C->unique() == unique, "non-optimize mode made Nodes? ? ?"); |
1577 return; | 1589 return; |
1578 } | 1590 } |
1579 if( VerifyLoopOptimizations ) verify(); | 1591 if( VerifyLoopOptimizations ) verify(); |
1676 // Build a verify-only PhaseIdealLoop, and see that it agrees with me. | 1688 // Build a verify-only PhaseIdealLoop, and see that it agrees with me. |
1677 static int fail; // debug only, so its multi-thread dont care | 1689 static int fail; // debug only, so its multi-thread dont care |
1678 void PhaseIdealLoop::verify() const { | 1690 void PhaseIdealLoop::verify() const { |
1679 int old_progress = C->major_progress(); | 1691 int old_progress = C->major_progress(); |
1680 ResourceMark rm; | 1692 ResourceMark rm; |
1681 PhaseIdealLoop loop_verify( _igvn, this, false ); | 1693 PhaseIdealLoop loop_verify( _igvn, this ); |
1682 VectorSet visited(Thread::current()->resource_area()); | 1694 VectorSet visited(Thread::current()->resource_area()); |
1683 | 1695 |
1684 fail = 0; | 1696 fail = 0; |
1685 verify_compare( C->root(), &loop_verify, visited ); | 1697 verify_compare( C->root(), &loop_verify, visited ); |
1686 assert( fail == 0, "verify loops failed" ); | 1698 assert( fail == 0, "verify loops failed" ); |
2136 // new loop exit. This would make the infinite loop a first-class | 2148 // new loop exit. This would make the infinite loop a first-class |
2137 // loop and it would then get properly optimized. What's the use of | 2149 // loop and it would then get properly optimized. What's the use of |
2138 // optimizing an infinite loop? | 2150 // optimizing an infinite loop? |
2139 l = _ltree_root; // Oops, found infinite loop | 2151 l = _ltree_root; // Oops, found infinite loop |
2140 | 2152 |
2141 // Insert the NeverBranch between 'm' and it's control user. | 2153 if (!_verify_only) { |
2142 NeverBranchNode *iff = new (C, 1) NeverBranchNode( m ); | 2154 // Insert the NeverBranch between 'm' and it's control user. |
2143 _igvn.register_new_node_with_optimizer(iff); | 2155 NeverBranchNode *iff = new (C, 1) NeverBranchNode( m ); |
2144 set_loop(iff, l); | 2156 _igvn.register_new_node_with_optimizer(iff); |
2145 Node *if_t = new (C, 1) CProjNode( iff, 0 ); | 2157 set_loop(iff, l); |
2146 _igvn.register_new_node_with_optimizer(if_t); | 2158 Node *if_t = new (C, 1) CProjNode( iff, 0 ); |
2147 set_loop(if_t, l); | 2159 _igvn.register_new_node_with_optimizer(if_t); |
2148 | 2160 set_loop(if_t, l); |
2149 Node* cfg = NULL; // Find the One True Control User of m | 2161 |
2150 for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) { | 2162 Node* cfg = NULL; // Find the One True Control User of m |
2151 Node* x = m->fast_out(j); | 2163 for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) { |
2152 if (x->is_CFG() && x != m && x != iff) | 2164 Node* x = m->fast_out(j); |
2153 { cfg = x; break; } | 2165 if (x->is_CFG() && x != m && x != iff) |
2166 { cfg = x; break; } | |
2167 } | |
2168 assert(cfg != NULL, "must find the control user of m"); | |
2169 uint k = 0; // Probably cfg->in(0) | |
2170 while( cfg->in(k) != m ) k++; // But check incase cfg is a Region | |
2171 cfg->set_req( k, if_t ); // Now point to NeverBranch | |
2172 | |
2173 // Now create the never-taken loop exit | |
2174 Node *if_f = new (C, 1) CProjNode( iff, 1 ); | |
2175 _igvn.register_new_node_with_optimizer(if_f); | |
2176 set_loop(if_f, l); | |
2177 // Find frame ptr for Halt. Relies on the optimizer | |
2178 // V-N'ing. Easier and quicker than searching through | |
2179 // the program structure. | |
2180 Node *frame = new (C, 1) ParmNode( C->start(), TypeFunc::FramePtr ); | |
2181 _igvn.register_new_node_with_optimizer(frame); | |
2182 // Halt & Catch Fire | |
2183 Node *halt = new (C, TypeFunc::Parms) HaltNode( if_f, frame ); | |
2184 _igvn.register_new_node_with_optimizer(halt); | |
2185 set_loop(halt, l); | |
2186 C->root()->add_req(halt); | |
2154 } | 2187 } |
2155 assert(cfg != NULL, "must find the control user of m"); | |
2156 uint k = 0; // Probably cfg->in(0) | |
2157 while( cfg->in(k) != m ) k++; // But check incase cfg is a Region | |
2158 cfg->set_req( k, if_t ); // Now point to NeverBranch | |
2159 | |
2160 // Now create the never-taken loop exit | |
2161 Node *if_f = new (C, 1) CProjNode( iff, 1 ); | |
2162 _igvn.register_new_node_with_optimizer(if_f); | |
2163 set_loop(if_f, l); | |
2164 // Find frame ptr for Halt. Relies on the optimizer | |
2165 // V-N'ing. Easier and quicker than searching through | |
2166 // the program structure. | |
2167 Node *frame = new (C, 1) ParmNode( C->start(), TypeFunc::FramePtr ); | |
2168 _igvn.register_new_node_with_optimizer(frame); | |
2169 // Halt & Catch Fire | |
2170 Node *halt = new (C, TypeFunc::Parms) HaltNode( if_f, frame ); | |
2171 _igvn.register_new_node_with_optimizer(halt); | |
2172 set_loop(halt, l); | |
2173 C->root()->add_req(halt); | |
2174 set_loop(C->root(), _ltree_root); | 2188 set_loop(C->root(), _ltree_root); |
2175 } | 2189 } |
2176 } | 2190 } |
2177 // Weeny check for irreducible. This child was already visited (this | 2191 // Weeny check for irreducible. This child was already visited (this |
2178 // IS the post-work phase). Is this child's loop header post-visited | 2192 // IS the post-work phase). Is this child's loop header post-visited |
2179 // as well? If so, then I found another entry into the loop. | 2193 // as well? If so, then I found another entry into the loop. |
2180 while( is_postvisited(l->_head) ) { | 2194 if (!_verify_only) { |
2181 // found irreducible | 2195 while( is_postvisited(l->_head) ) { |
2182 l->_irreducible = 1; // = true | 2196 // found irreducible |
2183 l = l->_parent; | 2197 l->_irreducible = 1; // = true |
2184 _has_irreducible_loops = true; | 2198 l = l->_parent; |
2185 // Check for bad CFG here to prevent crash, and bailout of compile | 2199 _has_irreducible_loops = true; |
2186 if (l == NULL) { | 2200 // Check for bad CFG here to prevent crash, and bailout of compile |
2187 C->record_method_not_compilable("unhandled CFG detected during loop optimization"); | 2201 if (l == NULL) { |
2188 return pre_order; | 2202 C->record_method_not_compilable("unhandled CFG detected during loop optimization"); |
2203 return pre_order; | |
2204 } | |
2189 } | 2205 } |
2190 } | 2206 } |
2191 | 2207 |
2192 // This Node might be a decision point for loops. It is only if | 2208 // This Node might be a decision point for loops. It is only if |
2193 // it's children belong to several different loops. The sort call | 2209 // it's children belong to several different loops. The sort call |
2251 | 2267 |
2252 //------------------------------build_loop_early------------------------------- | 2268 //------------------------------build_loop_early------------------------------- |
2253 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. | 2269 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. |
2254 // First pass computes the earliest controlling node possible. This is the | 2270 // First pass computes the earliest controlling node possible. This is the |
2255 // controlling input with the deepest dominating depth. | 2271 // controlling input with the deepest dominating depth. |
2256 void PhaseIdealLoop::build_loop_early( VectorSet &visited, Node_List &worklist, Node_Stack &nstack, const PhaseIdealLoop *verify_me ) { | 2272 void PhaseIdealLoop::build_loop_early( VectorSet &visited, Node_List &worklist, Node_Stack &nstack ) { |
2257 while (worklist.size() != 0) { | 2273 while (worklist.size() != 0) { |
2258 // Use local variables nstack_top_n & nstack_top_i to cache values | 2274 // Use local variables nstack_top_n & nstack_top_i to cache values |
2259 // on nstack's top. | 2275 // on nstack's top. |
2260 Node *nstack_top_n = worklist.pop(); | 2276 Node *nstack_top_n = worklist.pop(); |
2261 uint nstack_top_i = 0; | 2277 uint nstack_top_i = 0; |
2283 } | 2299 } |
2284 // Remove safepoints ONLY if I've already seen I don't need one. | 2300 // Remove safepoints ONLY if I've already seen I don't need one. |
2285 // (the old code here would yank a 2nd safepoint after seeing a | 2301 // (the old code here would yank a 2nd safepoint after seeing a |
2286 // first one, even though the 1st did not dominate in the loop body | 2302 // first one, even though the 1st did not dominate in the loop body |
2287 // and thus could be avoided indefinitely) | 2303 // and thus could be avoided indefinitely) |
2288 if( !verify_me && ilt->_has_sfpt && n->Opcode() == Op_SafePoint && | 2304 if( !_verify_only && !_verify_me && ilt->_has_sfpt && n->Opcode() == Op_SafePoint && |
2289 is_deleteable_safept(n)) { | 2305 is_deleteable_safept(n)) { |
2290 Node *in = n->in(TypeFunc::Control); | 2306 Node *in = n->in(TypeFunc::Control); |
2291 lazy_replace(n,in); // Pull safepoint now | 2307 lazy_replace(n,in); // Pull safepoint now |
2292 // Carry on with the recursion "as if" we are walking | 2308 // Carry on with the recursion "as if" we are walking |
2293 // only the control input | 2309 // only the control input |
2406 LCA = dom_lca( LCA, region->in(i) ); | 2422 LCA = dom_lca( LCA, region->in(i) ); |
2407 } | 2423 } |
2408 return LCA; | 2424 return LCA; |
2409 } | 2425 } |
2410 | 2426 |
2411 //------------------------------get_late_ctrl---------------------------------- | 2427 bool PhaseIdealLoop::verify_dominance(Node* n, Node* use, Node* LCA, Node* early) { |
2412 // Compute latest legal control. | 2428 bool had_error = false; |
2413 Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) { | 2429 #ifdef ASSERT |
2414 assert(early != NULL, "early control should not be NULL"); | 2430 if (early != C->root()) { |
2415 | 2431 // Make sure that there's a dominance path from use to LCA |
2432 Node* d = use; | |
2433 while (d != LCA) { | |
2434 d = idom(d); | |
2435 if (d == C->root()) { | |
2436 tty->print_cr("*** Use %d isn't dominated by def %s", use->_idx, n->_idx); | |
2437 n->dump(); | |
2438 use->dump(); | |
2439 had_error = true; | |
2440 break; | |
2441 } | |
2442 } | |
2443 } | |
2444 #endif | |
2445 return had_error; | |
2446 } | |
2447 | |
2448 | |
2449 Node* PhaseIdealLoop::compute_lca_of_uses(Node* n, Node* early, bool verify) { | |
2416 // Compute LCA over list of uses | 2450 // Compute LCA over list of uses |
2451 bool had_error = false; | |
2417 Node *LCA = NULL; | 2452 Node *LCA = NULL; |
2418 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax && LCA != early; i++) { | 2453 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax && LCA != early; i++) { |
2419 Node* c = n->fast_out(i); | 2454 Node* c = n->fast_out(i); |
2420 if (_nodes[c->_idx] == NULL) | 2455 if (_nodes[c->_idx] == NULL) |
2421 continue; // Skip the occasional dead node | 2456 continue; // Skip the occasional dead node |
2422 if( c->is_Phi() ) { // For Phis, we must land above on the path | 2457 if( c->is_Phi() ) { // For Phis, we must land above on the path |
2423 for( uint j=1; j<c->req(); j++ ) {// For all inputs | 2458 for( uint j=1; j<c->req(); j++ ) {// For all inputs |
2424 if( c->in(j) == n ) { // Found matching input? | 2459 if( c->in(j) == n ) { // Found matching input? |
2425 Node *use = c->in(0)->in(j); | 2460 Node *use = c->in(0)->in(j); |
2461 if (_verify_only && use->is_top()) continue; | |
2426 LCA = dom_lca_for_get_late_ctrl( LCA, use, n ); | 2462 LCA = dom_lca_for_get_late_ctrl( LCA, use, n ); |
2463 if (verify) had_error = verify_dominance(n, use, LCA, early) || had_error; | |
2427 } | 2464 } |
2428 } | 2465 } |
2429 } else { | 2466 } else { |
2430 // For CFG data-users, use is in the block just prior | 2467 // For CFG data-users, use is in the block just prior |
2431 Node *use = has_ctrl(c) ? get_ctrl(c) : c->in(0); | 2468 Node *use = has_ctrl(c) ? get_ctrl(c) : c->in(0); |
2432 LCA = dom_lca_for_get_late_ctrl( LCA, use, n ); | 2469 LCA = dom_lca_for_get_late_ctrl( LCA, use, n ); |
2433 } | 2470 if (verify) had_error = verify_dominance(n, use, LCA, early) || had_error; |
2434 } | 2471 } |
2472 } | |
2473 assert(!had_error, "bad dominance"); | |
2474 return LCA; | |
2475 } | |
2476 | |
2477 //------------------------------get_late_ctrl---------------------------------- | |
2478 // Compute latest legal control. | |
2479 Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) { | |
2480 assert(early != NULL, "early control should not be NULL"); | |
2481 | |
2482 Node* LCA = compute_lca_of_uses(n, early); | |
2483 #ifdef ASSERT | |
2484 if (LCA == C->root() && LCA != early) { | |
2485 // def doesn't dominate uses so print some useful debugging output | |
2486 compute_lca_of_uses(n, early, true); | |
2487 } | |
2488 #endif | |
2435 | 2489 |
2436 // if this is a load, check for anti-dependent stores | 2490 // if this is a load, check for anti-dependent stores |
2437 // We use a conservative algorithm to identify potential interfering | 2491 // We use a conservative algorithm to identify potential interfering |
2438 // instructions and for rescheduling the load. The users of the memory | 2492 // instructions and for rescheduling the load. The users of the memory |
2439 // input of this load are examined. Any use which is not a load and is | 2493 // input of this load are examined. Any use which is not a load and is |
2574 } | 2628 } |
2575 | 2629 |
2576 //------------------------------build_loop_late-------------------------------- | 2630 //------------------------------build_loop_late-------------------------------- |
2577 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. | 2631 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. |
2578 // Second pass finds latest legal placement, and ideal loop placement. | 2632 // Second pass finds latest legal placement, and ideal loop placement. |
2579 void PhaseIdealLoop::build_loop_late( VectorSet &visited, Node_List &worklist, Node_Stack &nstack, const PhaseIdealLoop *verify_me ) { | 2633 void PhaseIdealLoop::build_loop_late( VectorSet &visited, Node_List &worklist, Node_Stack &nstack ) { |
2580 while (worklist.size() != 0) { | 2634 while (worklist.size() != 0) { |
2581 Node *n = worklist.pop(); | 2635 Node *n = worklist.pop(); |
2582 // Only visit once | 2636 // Only visit once |
2583 if (visited.test_set(n->_idx)) continue; | 2637 if (visited.test_set(n->_idx)) continue; |
2584 uint cnt = n->outcnt(); | 2638 uint cnt = n->outcnt(); |
2610 // push dead code onto a worklist | 2664 // push dead code onto a worklist |
2611 _deadlist.push(use); | 2665 _deadlist.push(use); |
2612 } | 2666 } |
2613 } else { | 2667 } else { |
2614 // All of n's children have been processed, complete post-processing. | 2668 // All of n's children have been processed, complete post-processing. |
2615 build_loop_late_post(n, verify_me); | 2669 build_loop_late_post(n); |
2616 if (nstack.is_empty()) { | 2670 if (nstack.is_empty()) { |
2617 // Finished all nodes on stack. | 2671 // Finished all nodes on stack. |
2618 // Process next node on the worklist. | 2672 // Process next node on the worklist. |
2619 break; | 2673 break; |
2620 } | 2674 } |
2629 } | 2683 } |
2630 | 2684 |
2631 //------------------------------build_loop_late_post--------------------------- | 2685 //------------------------------build_loop_late_post--------------------------- |
2632 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. | 2686 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping. |
2633 // Second pass finds latest legal placement, and ideal loop placement. | 2687 // Second pass finds latest legal placement, and ideal loop placement. |
2634 void PhaseIdealLoop::build_loop_late_post( Node *n, const PhaseIdealLoop *verify_me ) { | 2688 void PhaseIdealLoop::build_loop_late_post( Node *n ) { |
2635 | 2689 |
2636 if (n->req() == 2 && n->Opcode() == Op_ConvI2L && !C->major_progress()) { | 2690 if (n->req() == 2 && n->Opcode() == Op_ConvI2L && !C->major_progress() && !_verify_only) { |
2637 _igvn._worklist.push(n); // Maybe we'll normalize it, if no more loops. | 2691 _igvn._worklist.push(n); // Maybe we'll normalize it, if no more loops. |
2638 } | 2692 } |
2639 | 2693 |
2640 // CFG and pinned nodes already handled | 2694 // CFG and pinned nodes already handled |
2641 if( n->in(0) ) { | 2695 if( n->in(0) ) { |
2712 legal = idom(legal); // Bump up the IDOM tree | 2766 legal = idom(legal); // Bump up the IDOM tree |
2713 // Check for lower nesting depth | 2767 // Check for lower nesting depth |
2714 if( get_loop(legal)->_nest < get_loop(least)->_nest ) | 2768 if( get_loop(legal)->_nest < get_loop(least)->_nest ) |
2715 least = legal; | 2769 least = legal; |
2716 } | 2770 } |
2771 assert(early == legal || legal != C->root(), "bad dominance of inputs"); | |
2717 | 2772 |
2718 // Try not to place code on a loop entry projection | 2773 // Try not to place code on a loop entry projection |
2719 // which can inhibit range check elimination. | 2774 // which can inhibit range check elimination. |
2720 if (least != early) { | 2775 if (least != early) { |
2721 Node* ctrl_out = least->unique_ctrl_out(); | 2776 Node* ctrl_out = least->unique_ctrl_out(); |
2729 } | 2784 } |
2730 | 2785 |
2731 #ifdef ASSERT | 2786 #ifdef ASSERT |
2732 // If verifying, verify that 'verify_me' has a legal location | 2787 // If verifying, verify that 'verify_me' has a legal location |
2733 // and choose it as our location. | 2788 // and choose it as our location. |
2734 if( verify_me ) { | 2789 if( _verify_me ) { |
2735 Node *v_ctrl = verify_me->get_ctrl_no_update(n); | 2790 Node *v_ctrl = _verify_me->get_ctrl_no_update(n); |
2736 Node *legal = LCA; | 2791 Node *legal = LCA; |
2737 while( early != legal ) { // While not at earliest legal | 2792 while( early != legal ) { // While not at earliest legal |
2738 if( legal == v_ctrl ) break; // Check for prior good location | 2793 if( legal == v_ctrl ) break; // Check for prior good location |
2739 legal = idom(legal) ;// Bump up the IDOM tree | 2794 legal = idom(legal) ;// Bump up the IDOM tree |
2740 } | 2795 } |