< prev index next >

src/share/vm/opto/loopTransform.cpp

Print this page




1396 //------------------------------do_unroll--------------------------------------
1397 // Unroll the loop body one step - make each trip do 2 iterations.
1398 void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip ) {
1399   assert(LoopUnrollLimit, "");
1400   CountedLoopNode *loop_head = loop->_head->as_CountedLoop();
1401   CountedLoopEndNode *loop_end = loop_head->loopexit();
1402   assert(loop_end, "");
1403 #ifndef PRODUCT
1404   if (PrintOpto && VerifyLoopOptimizations) {
1405     tty->print("Unrolling ");
1406     loop->dump_head();
1407   } else if (TraceLoopOpts) {
1408     if (loop_head->trip_count() < (uint)LoopUnrollLimit) {
1409       tty->print("Unroll %d(%2d) ", loop_head->unrolled_count()*2, loop_head->trip_count());
1410     } else {
1411       tty->print("Unroll %d     ", loop_head->unrolled_count()*2);
1412     }
1413     loop->dump_head();
1414   }
1415 
1416   if (C->do_vector_loop() && (PrintOpto && VerifyLoopOptimizations || TraceLoopOpts)) {
1417     Arena* arena = Thread::current()->resource_area();
1418     Node_Stack stack(arena, C->live_nodes() >> 2);
1419     Node_List rpo_list;
1420     VectorSet visited(arena);
1421     visited.set(loop_head->_idx);
1422     rpo( loop_head, stack, visited, rpo_list );
1423     dump(loop, rpo_list.size(), rpo_list );
1424   }
1425 #endif
1426 
1427   // Remember loop node count before unrolling to detect
1428   // if rounds of unroll,optimize are making progress
1429   loop_head->set_node_count_before_unroll(loop->_body.size());
1430 
1431   Node *ctrl  = loop_head->in(LoopNode::EntryControl);
1432   Node *limit = loop_head->limit();
1433   Node *init  = loop_head->init_trip();
1434   Node *stride = loop_head->stride();
1435 
1436   Node *opaq = NULL;


1635 
1636   // Kill the clone's backedge
1637   Node *newcle = old_new[loop_end->_idx];
1638   _igvn.hash_delete( newcle );
1639   Node *one = _igvn.intcon(1);
1640   set_ctrl(one, C->root());
1641   newcle->set_req(1, one);
1642   // Force clone into same loop body
1643   uint max = loop->_body.size();
1644   for( uint k = 0; k < max; k++ ) {
1645     Node *old = loop->_body.at(k);
1646     Node *nnn = old_new[old->_idx];
1647     loop->_body.push(nnn);
1648     if (!has_ctrl(old))
1649       set_loop(nnn, loop);
1650   }
1651 
1652   loop->record_for_igvn();
1653 
1654 #ifndef PRODUCT
1655   if (C->do_vector_loop() && (PrintOpto && VerifyLoopOptimizations || TraceLoopOpts)) {
1656     tty->print("\nnew loop after unroll\n");       loop->dump_head();
1657     for (uint i = 0; i < loop->_body.size(); i++) {
1658       loop->_body.at(i)->dump();
1659     }
1660     if(C->clone_map().is_debug()) {
1661       tty->print("\nCloneMap\n");
1662       Dict* dict = C->clone_map().dict();
1663       DictI i(dict);
1664       tty->print_cr("Dict@%p[%d] = ", dict, dict->Size());
1665       for (int ii = 0; i.test(); ++i, ++ii) {
1666         NodeCloneInfo cl((uint64_t)dict->operator[]((void*)i._key));
1667         tty->print("%d->%d:%d,", (int)(intptr_t)i._key, cl.idx(), cl.gen());
1668         if (ii % 10 == 9) {
1669           tty->print_cr(" ");
1670         }
1671       }
1672       tty->print_cr(" ");
1673     }
1674   }
1675 #endif




1396 //------------------------------do_unroll--------------------------------------
1397 // Unroll the loop body one step - make each trip do 2 iterations.
1398 void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip ) {
1399   assert(LoopUnrollLimit, "");
1400   CountedLoopNode *loop_head = loop->_head->as_CountedLoop();
1401   CountedLoopEndNode *loop_end = loop_head->loopexit();
1402   assert(loop_end, "");
1403 #ifndef PRODUCT
1404   if (PrintOpto && VerifyLoopOptimizations) {
1405     tty->print("Unrolling ");
1406     loop->dump_head();
1407   } else if (TraceLoopOpts) {
1408     if (loop_head->trip_count() < (uint)LoopUnrollLimit) {
1409       tty->print("Unroll %d(%2d) ", loop_head->unrolled_count()*2, loop_head->trip_count());
1410     } else {
1411       tty->print("Unroll %d     ", loop_head->unrolled_count()*2);
1412     }
1413     loop->dump_head();
1414   }
1415 
1416   if (C->do_vector_loop() && (PrintOpto && (VerifyLoopOptimizations || TraceLoopOpts))) {
1417     Arena* arena = Thread::current()->resource_area();
1418     Node_Stack stack(arena, C->live_nodes() >> 2);
1419     Node_List rpo_list;
1420     VectorSet visited(arena);
1421     visited.set(loop_head->_idx);
1422     rpo( loop_head, stack, visited, rpo_list );
1423     dump(loop, rpo_list.size(), rpo_list );
1424   }
1425 #endif
1426 
1427   // Remember loop node count before unrolling to detect
1428   // if rounds of unroll,optimize are making progress
1429   loop_head->set_node_count_before_unroll(loop->_body.size());
1430 
1431   Node *ctrl  = loop_head->in(LoopNode::EntryControl);
1432   Node *limit = loop_head->limit();
1433   Node *init  = loop_head->init_trip();
1434   Node *stride = loop_head->stride();
1435 
1436   Node *opaq = NULL;


1635 
1636   // Kill the clone's backedge
1637   Node *newcle = old_new[loop_end->_idx];
1638   _igvn.hash_delete( newcle );
1639   Node *one = _igvn.intcon(1);
1640   set_ctrl(one, C->root());
1641   newcle->set_req(1, one);
1642   // Force clone into same loop body
1643   uint max = loop->_body.size();
1644   for( uint k = 0; k < max; k++ ) {
1645     Node *old = loop->_body.at(k);
1646     Node *nnn = old_new[old->_idx];
1647     loop->_body.push(nnn);
1648     if (!has_ctrl(old))
1649       set_loop(nnn, loop);
1650   }
1651 
1652   loop->record_for_igvn();
1653 
1654 #ifndef PRODUCT
1655   if (C->do_vector_loop() && (PrintOpto && (VerifyLoopOptimizations || TraceLoopOpts))) {
1656     tty->print("\nnew loop after unroll\n");       loop->dump_head();
1657     for (uint i = 0; i < loop->_body.size(); i++) {
1658       loop->_body.at(i)->dump();
1659     }
1660     if(C->clone_map().is_debug()) {
1661       tty->print("\nCloneMap\n");
1662       Dict* dict = C->clone_map().dict();
1663       DictI i(dict);
1664       tty->print_cr("Dict@%p[%d] = ", dict, dict->Size());
1665       for (int ii = 0; i.test(); ++i, ++ii) {
1666         NodeCloneInfo cl((uint64_t)dict->operator[]((void*)i._key));
1667         tty->print("%d->%d:%d,", (int)(intptr_t)i._key, cl.idx(), cl.gen());
1668         if (ii % 10 == 9) {
1669           tty->print_cr(" ");
1670         }
1671       }
1672       tty->print_cr(" ");
1673     }
1674   }
1675 #endif


< prev index next >