600 if (body_size != tst_body_size) // Check for int overflow 601 return false; 602 if (new_body_size > unroll_limit || 603 // Unrolling can result in a large amount of node construction 604 new_body_size >= MaxNodeLimit - (uint) phase->C->live_nodes()) { 605 return false; 606 } 607 608 // Do not unroll a loop with String intrinsics code. 609 // String intrinsics are large and have loops. 610 for (uint k = 0; k < _body.size(); k++) { 611 Node* n = _body.at(k); 612 switch (n->Opcode()) { 613 case Op_StrComp: 614 case Op_StrEquals: 615 case Op_StrIndexOf: 616 case Op_EncodeISOArray: 617 case Op_AryEq: { 618 return false; 619 } 620 } // switch 621 } 622 623 return true; // Do maximally unroll 624 } 625 626 627 //------------------------------policy_unroll---------------------------------- 628 // Return TRUE or FALSE if the loop should be unrolled or not. Unroll if 629 // the loop is a CountedLoop and the body is small enough. 630 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { 631 632 CountedLoopNode *cl = _head->as_CountedLoop(); 633 assert(cl->is_normal_loop() || cl->is_main_loop(), ""); 634 635 if (!cl->is_valid_counted_loop()) 636 return false; // Malformed counted loop 637 638 // Protect against over-unrolling. 639 // After split at least one iteration will be executed in pre-loop. 705 uint body_size = _body.size(); 706 // Key test to unroll loop in CRC32 java code 707 int xors_in_loop = 0; 708 // Also count ModL, DivL and MulL which expand mightly 709 for (uint k = 0; k < _body.size(); k++) { 710 Node* n = _body.at(k); 711 switch (n->Opcode()) { 712 case Op_XorI: xors_in_loop++; break; // CRC32 java code 713 case Op_ModL: body_size += 30; break; 714 case Op_DivL: body_size += 30; break; 715 case Op_MulL: body_size += 10; break; 716 case Op_StrComp: 717 case Op_StrEquals: 718 case Op_StrIndexOf: 719 case Op_EncodeISOArray: 720 case Op_AryEq: { 721 // Do not unroll a loop with String intrinsics code. 722 // String intrinsics are large and have loops. 723 return false; 724 } 725 } // switch 726 } 727 728 // Check for being too big 729 if (body_size > (uint)LoopUnrollLimit) { 730 if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true; 731 // Normal case: loop too big 732 return false; 733 } 734 735 // Unroll once! (Each trip will soon do double iterations) 736 return true; 737 } 738 739 //------------------------------policy_align----------------------------------- 740 // Return TRUE or FALSE if the loop should be cache-line aligned. Gather the 741 // expression that does the alignment. Note that only one array base can be 742 // aligned in a loop (unless the VM guarantees mutual alignment). Note that 743 // if we vectorize short memory ops into longer memory ops, we may want to 744 // increase alignment. | 600 if (body_size != tst_body_size) // Check for int overflow 601 return false; 602 if (new_body_size > unroll_limit || 603 // Unrolling can result in a large amount of node construction 604 new_body_size >= MaxNodeLimit - (uint) phase->C->live_nodes()) { 605 return false; 606 } 607 608 // Do not unroll a loop with String intrinsics code. 609 // String intrinsics are large and have loops. 610 for (uint k = 0; k < _body.size(); k++) { 611 Node* n = _body.at(k); 612 switch (n->Opcode()) { 613 case Op_StrComp: 614 case Op_StrEquals: 615 case Op_StrIndexOf: 616 case Op_EncodeISOArray: 617 case Op_AryEq: { 618 return false; 619 } 620 #if INCLUDE_RTM_OPT 621 case Op_FastLock: 622 case Op_FastUnlock: { 623 // Don't unroll RTM locking code because it is large. 624 if (UseRTMLocking) { 625 return false; 626 } 627 } 628 #endif 629 } // switch 630 } 631 632 return true; // Do maximally unroll 633 } 634 635 636 //------------------------------policy_unroll---------------------------------- 637 // Return TRUE or FALSE if the loop should be unrolled or not. Unroll if 638 // the loop is a CountedLoop and the body is small enough. 639 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { 640 641 CountedLoopNode *cl = _head->as_CountedLoop(); 642 assert(cl->is_normal_loop() || cl->is_main_loop(), ""); 643 644 if (!cl->is_valid_counted_loop()) 645 return false; // Malformed counted loop 646 647 // Protect against over-unrolling. 648 // After split at least one iteration will be executed in pre-loop. 714 uint body_size = _body.size(); 715 // Key test to unroll loop in CRC32 java code 716 int xors_in_loop = 0; 717 // Also count ModL, DivL and MulL which expand mightly 718 for (uint k = 0; k < _body.size(); k++) { 719 Node* n = _body.at(k); 720 switch (n->Opcode()) { 721 case Op_XorI: xors_in_loop++; break; // CRC32 java code 722 case Op_ModL: body_size += 30; break; 723 case Op_DivL: body_size += 30; break; 724 case Op_MulL: body_size += 10; break; 725 case Op_StrComp: 726 case Op_StrEquals: 727 case Op_StrIndexOf: 728 case Op_EncodeISOArray: 729 case Op_AryEq: { 730 // Do not unroll a loop with String intrinsics code. 731 // String intrinsics are large and have loops. 732 return false; 733 } 734 #if INCLUDE_RTM_OPT 735 case Op_FastLock: 736 case Op_FastUnlock: { 737 // Don't unroll RTM locking code because it is large. 738 if (UseRTMLocking) { 739 return false; 740 } 741 } 742 #endif 743 } // switch 744 } 745 746 // Check for being too big 747 if (body_size > (uint)LoopUnrollLimit) { 748 if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true; 749 // Normal case: loop too big 750 return false; 751 } 752 753 // Unroll once! (Each trip will soon do double iterations) 754 return true; 755 } 756 757 //------------------------------policy_align----------------------------------- 758 // Return TRUE or FALSE if the loop should be cache-line aligned. Gather the 759 // expression that does the alignment. Note that only one array base can be 760 // aligned in a loop (unless the VM guarantees mutual alignment). Note that 761 // if we vectorize short memory ops into longer memory ops, we may want to 762 // increase alignment. |