hotspot/src/share/vm/opto/loopTransform.cpp
changeset 10538 d6bf448fa3ad
parent 10263 fa58671dde31
child 12958 009b6c9586d8
equal deleted inserted replaced
10518:71e6d7ccdc8d 10538:d6bf448fa3ad
   707       stride_con < 0 && ((limit_type->_lo - stride_con) <= limit_type->_lo))
   707       stride_con < 0 && ((limit_type->_lo - stride_con) <= limit_type->_lo))
   708     return false;  // overflow
   708     return false;  // overflow
   709 
   709 
   710   // Adjust body_size to determine if we unroll or not
   710   // Adjust body_size to determine if we unroll or not
   711   uint body_size = _body.size();
   711   uint body_size = _body.size();
       
   712   // Key test to unroll loop in CRC32 java code
       
   713   int xors_in_loop = 0;
   712   // Also count ModL, DivL and MulL which expand mightly
   714   // Also count ModL, DivL and MulL which expand mightly
   713   for (uint k = 0; k < _body.size(); k++) {
   715   for (uint k = 0; k < _body.size(); k++) {
   714     Node* n = _body.at(k);
   716     Node* n = _body.at(k);
   715     switch (n->Opcode()) {
   717     switch (n->Opcode()) {
       
   718       case Op_XorI: xors_in_loop++; break; // CRC32 java code
   716       case Op_ModL: body_size += 30; break;
   719       case Op_ModL: body_size += 30; break;
   717       case Op_DivL: body_size += 30; break;
   720       case Op_DivL: body_size += 30; break;
   718       case Op_MulL: body_size += 10; break;
   721       case Op_MulL: body_size += 10; break;
   719       case Op_StrComp:
   722       case Op_StrComp:
   720       case Op_StrEquals:
   723       case Op_StrEquals:
   727     } // switch
   730     } // switch
   728   }
   731   }
   729 
   732 
   730   // Check for being too big
   733   // Check for being too big
   731   if (body_size > (uint)LoopUnrollLimit) {
   734   if (body_size > (uint)LoopUnrollLimit) {
   732      // Normal case: loop too big
   735     if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true;
       
   736     // Normal case: loop too big
   733     return false;
   737     return false;
   734   }
   738   }
   735 
   739 
   736   // Unroll once!  (Each trip will soon do double iterations)
   740   // Unroll once!  (Each trip will soon do double iterations)
   737   return true;
   741   return true;