< prev index next >

src/share/vm/opto/loopTransform.cpp

Print this page




 605   // Take into account that after unroll conjoined heads and tails will fold,
 606   // otherwise policy_unroll() may allow more unrolling than max unrolling.
 607   uint new_body_size = EMPTY_LOOP_SIZE + (body_size - EMPTY_LOOP_SIZE) * trip_count;
 608   uint tst_body_size = (new_body_size - EMPTY_LOOP_SIZE) / trip_count + EMPTY_LOOP_SIZE;
 609   if (body_size != tst_body_size) // Check for int overflow
 610     return false;
 611   if (new_body_size > unroll_limit ||
 612       // Unrolling can result in a large amount of node construction
 613       new_body_size >= phase->C->max_node_limit() - phase->C->live_nodes()) {
 614     return false;
 615   }
 616 
 617   // Do not unroll a loop with String intrinsics code.
 618   // String intrinsics are large and have loops.
 619   for (uint k = 0; k < _body.size(); k++) {
 620     Node* n = _body.at(k);
 621     switch (n->Opcode()) {
 622       case Op_StrComp:
 623       case Op_StrEquals:
 624       case Op_StrIndexOf:

 625       case Op_EncodeISOArray:
 626       case Op_AryEq: {

 627         return false;
 628       }
 629 #if INCLUDE_RTM_OPT
 630       case Op_FastLock:
 631       case Op_FastUnlock: {
 632         // Don't unroll RTM locking code because it is large.
 633         if (UseRTMLocking) {
 634           return false;
 635         }
 636       }
 637 #endif
 638     } // switch
 639   }
 640 
 641   return true; // Do maximally unroll
 642 }
 643 
 644 
 645 //------------------------------policy_unroll----------------------------------
 646 // Return TRUE or FALSE if the loop should be unrolled or not.  Unroll if


 724   const TypeInt* limit_type = phase->_igvn.type(limit_n)->is_int();
 725   if (stride_con > 0 && ((limit_type->_hi - stride_con) >= limit_type->_hi) ||
 726       stride_con < 0 && ((limit_type->_lo - stride_con) <= limit_type->_lo))
 727     return false;  // overflow
 728 
 729   // Adjust body_size to determine if we unroll or not
 730   uint body_size = _body.size();
 731   // Key test to unroll loop in CRC32 java code
 732   int xors_in_loop = 0;
 733   // Also count ModL, DivL and MulL which expand mightly
 734   for (uint k = 0; k < _body.size(); k++) {
 735     Node* n = _body.at(k);
 736     switch (n->Opcode()) {
 737       case Op_XorI: xors_in_loop++; break; // CRC32 java code
 738       case Op_ModL: body_size += 30; break;
 739       case Op_DivL: body_size += 30; break;
 740       case Op_MulL: body_size += 10; break;
 741       case Op_StrComp:
 742       case Op_StrEquals:
 743       case Op_StrIndexOf:

 744       case Op_EncodeISOArray:
 745       case Op_AryEq: {

 746         // Do not unroll a loop with String intrinsics code.
 747         // String intrinsics are large and have loops.
 748         return false;
 749       }
 750 #if INCLUDE_RTM_OPT
 751       case Op_FastLock:
 752       case Op_FastUnlock: {
 753         // Don't unroll RTM locking code because it is large.
 754         if (UseRTMLocking) {
 755           return false;
 756         }
 757       }
 758 #endif
 759     } // switch
 760   }
 761 
 762   if (UseSuperWord) {
 763     if (!cl->is_reduction_loop()) {
 764       phase->mark_reductions(this);
 765     }




 605   // Take into account that after unroll conjoined heads and tails will fold,
 606   // otherwise policy_unroll() may allow more unrolling than max unrolling.
 607   uint new_body_size = EMPTY_LOOP_SIZE + (body_size - EMPTY_LOOP_SIZE) * trip_count;
 608   uint tst_body_size = (new_body_size - EMPTY_LOOP_SIZE) / trip_count + EMPTY_LOOP_SIZE;
 609   if (body_size != tst_body_size) // Check for int overflow
 610     return false;
 611   if (new_body_size > unroll_limit ||
 612       // Unrolling can result in a large amount of node construction
 613       new_body_size >= phase->C->max_node_limit() - phase->C->live_nodes()) {
 614     return false;
 615   }
 616 
 617   // Do not unroll a loop with String intrinsics code.
 618   // String intrinsics are large and have loops.
 619   for (uint k = 0; k < _body.size(); k++) {
 620     Node* n = _body.at(k);
 621     switch (n->Opcode()) {
 622       case Op_StrComp:
 623       case Op_StrEquals:
 624       case Op_StrIndexOf:
 625       case Op_StrIndexOfChar:
 626       case Op_EncodeISOArray:
 627       case Op_AryEq:
 628       case Op_HasNegatives: {
 629         return false;
 630       }
 631 #if INCLUDE_RTM_OPT
 632       case Op_FastLock:
 633       case Op_FastUnlock: {
 634         // Don't unroll RTM locking code because it is large.
 635         if (UseRTMLocking) {
 636           return false;
 637         }
 638       }
 639 #endif
 640     } // switch
 641   }
 642 
 643   return true; // Do maximally unroll
 644 }
 645 
 646 
 647 //------------------------------policy_unroll----------------------------------
 648 // Return TRUE or FALSE if the loop should be unrolled or not.  Unroll if


 726   const TypeInt* limit_type = phase->_igvn.type(limit_n)->is_int();
 727   if (stride_con > 0 && ((limit_type->_hi - stride_con) >= limit_type->_hi) ||
 728       stride_con < 0 && ((limit_type->_lo - stride_con) <= limit_type->_lo))
 729     return false;  // overflow
 730 
 731   // Adjust body_size to determine if we unroll or not
 732   uint body_size = _body.size();
 733   // Key test to unroll loop in CRC32 java code
 734   int xors_in_loop = 0;
 735   // Also count ModL, DivL and MulL which expand mightly
 736   for (uint k = 0; k < _body.size(); k++) {
 737     Node* n = _body.at(k);
 738     switch (n->Opcode()) {
 739       case Op_XorI: xors_in_loop++; break; // CRC32 java code
 740       case Op_ModL: body_size += 30; break;
 741       case Op_DivL: body_size += 30; break;
 742       case Op_MulL: body_size += 10; break;
 743       case Op_StrComp:
 744       case Op_StrEquals:
 745       case Op_StrIndexOf:
 746       case Op_StrIndexOfChar:
 747       case Op_EncodeISOArray:
 748       case Op_AryEq:
 749       case Op_HasNegatives: {
 750         // Do not unroll a loop with String intrinsics code.
 751         // String intrinsics are large and have loops.
 752         return false;
 753       }
 754 #if INCLUDE_RTM_OPT
 755       case Op_FastLock:
 756       case Op_FastUnlock: {
 757         // Don't unroll RTM locking code because it is large.
 758         if (UseRTMLocking) {
 759           return false;
 760         }
 761       }
 762 #endif
 763     } // switch
 764   }
 765 
 766   if (UseSuperWord) {
 767     if (!cl->is_reduction_loop()) {
 768       phase->mark_reductions(this);
 769     }


< prev index next >