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

src/share/vm/opto/loopnode.cpp

Print this page




 672 #ifdef ASSERT
 673   assert(l->is_valid_counted_loop(), "counted loop shape is messed up");
 674   assert(l == loop->_head && l->phi() == phi && l->loopexit() == lex, "" );
 675 #endif
 676 #ifndef PRODUCT
 677   if (TraceLoopOpts) {
 678     tty->print("Counted      ");
 679     loop->dump_head();
 680   }
 681 #endif
 682 
 683   C->print_method("After CountedLoop", 3);
 684 
 685   return true;
 686 }
 687 
 688 //----------------------exact_limit-------------------------------------------
 689 Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) {
 690   assert(loop->_head->is_CountedLoop(), "");
 691   CountedLoopNode *cl = loop->_head->as_CountedLoop();

 692 
 693   if (!LoopLimitCheck || ABS(cl->stride_con()) == 1 ||
 694       cl->limit()->Opcode() == Op_LoopLimit) {
 695     // Old code has exact limit (it could be incorrect in case of int overflow).
 696     // Loop limit is exact with stride == 1. And loop may already have exact limit.
 697     return cl->limit();
 698   }
 699   Node *limit = NULL;
 700 #ifdef ASSERT
 701   BoolTest::mask bt = cl->loopexit()->test_trip();
 702   assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected");
 703 #endif
 704   if (cl->has_exact_trip_count()) {
 705     // Simple case: loop has constant boundaries.
 706     // Use longs to avoid integer overflow.
 707     int stride_con = cl->stride_con();
 708     long  init_con = cl->init_trip()->get_int();
 709     long limit_con = cl->limit()->get_int();
 710     julong trip_cnt = cl->trip_count();
 711     long final_con = init_con + trip_cnt*stride_con;


1591   assert(sfpt->Opcode() == Op_SafePoint, "");
1592   IdealLoopTree* lp = get_loop(sfpt)->_parent;
1593   while (lp != NULL) {
1594     Node_List* sfpts = lp->_required_safept;
1595     if (sfpts != NULL) {
1596       for (uint i = 0; i < sfpts->size(); i++) {
1597         if (sfpt == sfpts->at(i))
1598           return false;
1599       }
1600     }
1601     lp = lp->_parent;
1602   }
1603   return true;
1604 }
1605 
1606 //---------------------------replace_parallel_iv-------------------------------
1607 // Replace parallel induction variable (parallel to trip counter)
1608 void PhaseIdealLoop::replace_parallel_iv(IdealLoopTree *loop) {
1609   assert(loop->_head->is_CountedLoop(), "");
1610   CountedLoopNode *cl = loop->_head->as_CountedLoop();


1611   Node *incr = cl->incr();
1612   if (incr == NULL)
1613     return;         // Dead loop?
1614   Node *init = cl->init_trip();
1615   Node *phi  = cl->phi();
1616   // protect against stride not being a constant
1617   if (!cl->stride_is_con())
1618     return;
1619   int stride_con = cl->stride_con();
1620 
1621   PhaseGVN *gvn = &_igvn;
1622 
1623   // Visit all children, looking for Phis
1624   for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
1625     Node *out = cl->out(i);
1626     // Look for other phis (secondary IVs). Skip dead ones
1627     if (!out->is_Phi() || out == phi || !has_node(out))
1628       continue;
1629     PhiNode* phi2 = out->as_Phi();
1630     Node *incr2 = phi2->in( LoopNode::LoopBackControl );
1631     // Look for induction variables of the form:  X += constant
1632     if (phi2->region() != loop->_head ||
1633         incr2->req() != 3 ||
1634         incr2->in(1) != phi2 ||
1635         incr2 == incr ||
1636         incr2->Opcode() != Op_AddI ||
1637         !incr2->in(2)->is_Con())
1638       continue;




 672 #ifdef ASSERT
 673   assert(l->is_valid_counted_loop(), "counted loop shape is messed up");
 674   assert(l == loop->_head && l->phi() == phi && l->loopexit() == lex, "" );
 675 #endif
 676 #ifndef PRODUCT
 677   if (TraceLoopOpts) {
 678     tty->print("Counted      ");
 679     loop->dump_head();
 680   }
 681 #endif
 682 
 683   C->print_method("After CountedLoop", 3);
 684 
 685   return true;
 686 }
 687 
 688 //----------------------exact_limit-------------------------------------------
 689 Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) {
 690   assert(loop->_head->is_CountedLoop(), "");
 691   CountedLoopNode *cl = loop->_head->as_CountedLoop();
 692   assert(cl->is_valid_counted_loop(), "");
 693 
 694   if (!LoopLimitCheck || ABS(cl->stride_con()) == 1 ||
 695       cl->limit()->Opcode() == Op_LoopLimit) {
 696     // Old code has exact limit (it could be incorrect in case of int overflow).
 697     // Loop limit is exact with stride == 1. And loop may already have exact limit.
 698     return cl->limit();
 699   }
 700   Node *limit = NULL;
 701 #ifdef ASSERT
 702   BoolTest::mask bt = cl->loopexit()->test_trip();
 703   assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected");
 704 #endif
 705   if (cl->has_exact_trip_count()) {
 706     // Simple case: loop has constant boundaries.
 707     // Use longs to avoid integer overflow.
 708     int stride_con = cl->stride_con();
 709     long  init_con = cl->init_trip()->get_int();
 710     long limit_con = cl->limit()->get_int();
 711     julong trip_cnt = cl->trip_count();
 712     long final_con = init_con + trip_cnt*stride_con;


1592   assert(sfpt->Opcode() == Op_SafePoint, "");
1593   IdealLoopTree* lp = get_loop(sfpt)->_parent;
1594   while (lp != NULL) {
1595     Node_List* sfpts = lp->_required_safept;
1596     if (sfpts != NULL) {
1597       for (uint i = 0; i < sfpts->size(); i++) {
1598         if (sfpt == sfpts->at(i))
1599           return false;
1600       }
1601     }
1602     lp = lp->_parent;
1603   }
1604   return true;
1605 }
1606 
1607 //---------------------------replace_parallel_iv-------------------------------
1608 // Replace parallel induction variable (parallel to trip counter)
1609 void PhaseIdealLoop::replace_parallel_iv(IdealLoopTree *loop) {
1610   assert(loop->_head->is_CountedLoop(), "");
1611   CountedLoopNode *cl = loop->_head->as_CountedLoop();
1612   if (!cl->is_valid_counted_loop())
1613     return;         // skip malformed counted loop
1614   Node *incr = cl->incr();
1615   if (incr == NULL)
1616     return;         // Dead loop?
1617   Node *init = cl->init_trip();
1618   Node *phi  = cl->phi();



1619   int stride_con = cl->stride_con();
1620 
1621   PhaseGVN *gvn = &_igvn;
1622 
1623   // Visit all children, looking for Phis
1624   for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
1625     Node *out = cl->out(i);
1626     // Look for other phis (secondary IVs). Skip dead ones
1627     if (!out->is_Phi() || out == phi || !has_node(out))
1628       continue;
1629     PhiNode* phi2 = out->as_Phi();
1630     Node *incr2 = phi2->in( LoopNode::LoopBackControl );
1631     // Look for induction variables of the form:  X += constant
1632     if (phi2->region() != loop->_head ||
1633         incr2->req() != 3 ||
1634         incr2->in(1) != phi2 ||
1635         incr2 == incr ||
1636         incr2->Opcode() != Op_AddI ||
1637         !incr2->in(2)->is_Con())
1638       continue;


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