< prev index next >

src/share/vm/opto/loopTransform.cpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "opto/addnode.hpp"
  29 #include "opto/callnode.hpp"
  30 #include "opto/castnode.hpp"
  31 #include "opto/connode.hpp"
  32 #include "opto/convertnode.hpp"
  33 #include "opto/divnode.hpp"
  34 #include "opto/loopnode.hpp"
  35 #include "opto/mulnode.hpp"
  36 #include "opto/movenode.hpp"
  37 #include "opto/opaquenode.hpp"
  38 #include "opto/rootnode.hpp"
  39 #include "opto/runtime.hpp"
  40 #include "opto/subnode.hpp"

  41 #include "opto/vectornode.hpp"
  42 
  43 //------------------------------is_loop_exit-----------------------------------
  44 // Given an IfNode, return the loop-exiting projection or NULL if both
  45 // arms remain in the loop.
  46 Node *IdealLoopTree::is_loop_exit(Node *iff) const {
  47   if( iff->outcnt() != 2 ) return NULL; // Ignore partially dead tests
  48   PhaseIdealLoop *phase = _phase;
  49   // Test is an IfNode, has 2 projections.  If BOTH are in the loop
  50   // we need loop unswitching instead of peeling.
  51   if( !is_member(phase->get_loop( iff->raw_out(0) )) )
  52     return iff->raw_out(0);
  53   if( !is_member(phase->get_loop( iff->raw_out(1) )) )
  54     return iff->raw_out(1);
  55   return NULL;
  56 }
  57 
  58 
  59 //=============================================================================
  60 


 623       }
 624 #if INCLUDE_RTM_OPT
 625       case Op_FastLock:
 626       case Op_FastUnlock: {
 627         // Don't unroll RTM locking code because it is large.
 628         if (UseRTMLocking) {
 629           return false;
 630         }
 631       }
 632 #endif
 633     } // switch
 634   }
 635 
 636   return true; // Do maximally unroll
 637 }
 638 
 639 
 640 //------------------------------policy_unroll----------------------------------
 641 // Return TRUE or FALSE if the loop should be unrolled or not.  Unroll if
 642 // the loop is a CountedLoop and the body is small enough.
 643 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const {
 644 
 645   CountedLoopNode *cl = _head->as_CountedLoop();
 646   assert(cl->is_normal_loop() || cl->is_main_loop(), "");
 647 
 648   if (!cl->is_valid_counted_loop())
 649     return false; // Malformed counted loop
 650 
 651   // Protect against over-unrolling.
 652   // After split at least one iteration will be executed in pre-loop.
 653   if (cl->trip_count() <= (uint)(cl->is_normal_loop() ? 2 : 1)) return false;
 654 


 655   int future_unroll_ct = cl->unrolled_count() * 2;
 656   if (future_unroll_ct > LoopMaxUnroll) return false;
 657 



































 658   // Check for initial stride being a small enough constant
 659   if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false;
 660 
 661   // Don't unroll if the next round of unrolling would push us
 662   // over the expected trip count of the loop.  One is subtracted
 663   // from the expected trip count because the pre-loop normally
 664   // executes 1 iteration.
 665   if (UnrollLimitForProfileCheck > 0 &&
 666       cl->profile_trip_cnt() != COUNT_UNKNOWN &&
 667       future_unroll_ct        > UnrollLimitForProfileCheck &&
 668       (float)future_unroll_ct > cl->profile_trip_cnt() - 1.0) {
 669     return false;
 670   }
 671 
 672   // When unroll count is greater than LoopUnrollMin, don't unroll if:
 673   //   the residual iterations are more than 10% of the trip count
 674   //   and rounds of "unroll,optimize" are not making significant progress
 675   //   Progress defined as current size less than 20% larger than previous size.
 676   if (UseSuperWord && cl->node_count_before_unroll() > 0 &&
 677       future_unroll_ct > LoopUnrollMin &&


 731       case Op_StrIndexOf:
 732       case Op_EncodeISOArray:
 733       case Op_AryEq: {
 734         // Do not unroll a loop with String intrinsics code.
 735         // String intrinsics are large and have loops.
 736         return false;
 737       }
 738 #if INCLUDE_RTM_OPT
 739       case Op_FastLock:
 740       case Op_FastUnlock: {
 741         // Don't unroll RTM locking code because it is large.
 742         if (UseRTMLocking) {
 743           return false;
 744         }
 745       }
 746 #endif
 747     } // switch
 748   }
 749 
 750   // Check for being too big
 751   if (body_size > (uint)LoopUnrollLimit) {
 752     if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true;
 753     // Normal case: loop too big
 754     return false;
 755   }
 756 
 757   // Unroll once!  (Each trip will soon do double iterations)
 758   return true;
 759 }
 760 






































































































































































 761 //------------------------------policy_align-----------------------------------
 762 // Return TRUE or FALSE if the loop should be cache-line aligned.  Gather the
 763 // expression that does the alignment.  Note that only one array base can be
 764 // aligned in a loop (unless the VM guarantees mutual alignment).  Note that
 765 // if we vectorize short memory ops into longer memory ops, we may want to
 766 // increase alignment.
 767 bool IdealLoopTree::policy_align( PhaseIdealLoop *phase ) const {
 768   return false;
 769 }
 770 
 771 //------------------------------policy_range_check-----------------------------
 772 // Return TRUE or FALSE if the loop should be range-check-eliminated.
 773 // Actually we do iteration-splitting, a more powerful form of RCE.
 774 bool IdealLoopTree::policy_range_check( PhaseIdealLoop *phase ) const {
 775   if (!RangeCheckElimination) return false;
 776 
 777   CountedLoopNode *cl = _head->as_CountedLoop();
 778   // If we unrolled with no intention of doing RCE and we later
 779   // changed our minds, we got no pre-loop.  Either we need to
 780   // make a new pre-loop, or we gotta disallow RCE.


1534   }
1535 
1536   Node* trip_phi = loop_head->phi();
1537   for (DUIterator_Fast imax, i = loop_head->fast_outs(imax); i < imax; i++) {
1538     Node* phi = loop_head->fast_out(i);
1539     if (phi->is_Phi() && phi->outcnt() > 0 && phi != trip_phi) {
1540       // For definitions which are loop inclusive and not tripcounts.
1541       Node* def_node = phi->in(LoopNode::LoopBackControl);
1542 
1543       if (def_node != NULL) {
1544         Node* n_ctrl = get_ctrl(def_node);
1545         if (n_ctrl != NULL && loop->is_member(get_loop(n_ctrl))) {
1546           // Now test it to see if it fits the standard pattern for a reduction operator.
1547           int opc = def_node->Opcode();
1548           if (opc != ReductionNode::opcode(opc, def_node->bottom_type()->basic_type())) {
1549             if (!def_node->is_reduction()) { // Not marked yet
1550               // To be a reduction, the arithmetic node must have the phi as input and provide a def to it
1551               for (unsigned j = 1; j < def_node->req(); j++) {
1552                 Node* in = def_node->in(j);
1553                 if (in == phi) {

1554                   def_node->add_flag(Node::Flag_is_reduction);
1555                   break;
1556                 }
1557               }
1558             }
1559           }
1560         }
1561       }
1562     }
1563   }
1564 }
1565 
1566 //------------------------------dominates_backedge---------------------------------
1567 // Returns true if ctrl is executed on every complete iteration
1568 bool IdealLoopTree::dominates_backedge(Node* ctrl) {
1569   assert(ctrl->is_CFG(), "must be control");
1570   Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
1571   return _phase->dom_lca_internal(ctrl, backedge) == ctrl;
1572 }
1573 


2384 
2385   // If we have any of these conditions (RCE, alignment, unrolling) met, then
2386   // we switch to the pre-/main-/post-loop model.  This model also covers
2387   // peeling.
2388   if (should_rce || should_align || should_unroll) {
2389     if (cl->is_normal_loop())  // Convert to 'pre/main/post' loops
2390       phase->insert_pre_post_loops(this,old_new, !may_rce_align);
2391 
2392     // Adjust the pre- and main-loop limits to let the pre and post loops run
2393     // with full checks, but the main-loop with no checks.  Remove said
2394     // checks from the main body.
2395     if (should_rce)
2396       phase->do_range_check(this,old_new);
2397 
2398     // Double loop body for unrolling.  Adjust the minimum-trip test (will do
2399     // twice as many iterations as before) and the main body limit (only do
2400     // an even number of trips).  If we are peeling, we might enable some RCE
2401     // and we'd rather unroll the post-RCE'd loop SO... do not unroll if
2402     // peeling.
2403     if (should_unroll && !should_peel) {
2404       phase->mark_reductions(this);
2405       phase->do_unroll(this, old_new, true);
2406     }
2407 
2408     // Adjust the pre-loop limits to align the main body
2409     // iterations.
2410     if (should_align)
2411       Unimplemented();
2412 
2413   } else {                      // Else we have an unchanged counted loop
2414     if (should_peel)           // Might want to peel but do nothing else
2415       phase->do_peeling(this,old_new);
2416   }
2417   return true;
2418 }
2419 
2420 
2421 //=============================================================================
2422 //------------------------------iteration_split--------------------------------
2423 bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new ) {
2424   // Recursively iteration split nested loops




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "opto/addnode.hpp"
  29 #include "opto/callnode.hpp"
  30 #include "opto/castnode.hpp"
  31 #include "opto/connode.hpp"
  32 #include "opto/convertnode.hpp"
  33 #include "opto/divnode.hpp"
  34 #include "opto/loopnode.hpp"
  35 #include "opto/mulnode.hpp"
  36 #include "opto/movenode.hpp"
  37 #include "opto/opaquenode.hpp"
  38 #include "opto/rootnode.hpp"
  39 #include "opto/runtime.hpp"
  40 #include "opto/subnode.hpp"
  41 #include "opto/superword.hpp"
  42 #include "opto/vectornode.hpp"
  43 
  44 //------------------------------is_loop_exit-----------------------------------
  45 // Given an IfNode, return the loop-exiting projection or NULL if both
  46 // arms remain in the loop.
  47 Node *IdealLoopTree::is_loop_exit(Node *iff) const {
  48   if( iff->outcnt() != 2 ) return NULL; // Ignore partially dead tests
  49   PhaseIdealLoop *phase = _phase;
  50   // Test is an IfNode, has 2 projections.  If BOTH are in the loop
  51   // we need loop unswitching instead of peeling.
  52   if( !is_member(phase->get_loop( iff->raw_out(0) )) )
  53     return iff->raw_out(0);
  54   if( !is_member(phase->get_loop( iff->raw_out(1) )) )
  55     return iff->raw_out(1);
  56   return NULL;
  57 }
  58 
  59 
  60 //=============================================================================
  61 


 624       }
 625 #if INCLUDE_RTM_OPT
 626       case Op_FastLock:
 627       case Op_FastUnlock: {
 628         // Don't unroll RTM locking code because it is large.
 629         if (UseRTMLocking) {
 630           return false;
 631         }
 632       }
 633 #endif
 634     } // switch
 635   }
 636 
 637   return true; // Do maximally unroll
 638 }
 639 
 640 
 641 //------------------------------policy_unroll----------------------------------
 642 // Return TRUE or FALSE if the loop should be unrolled or not.  Unroll if
 643 // the loop is a CountedLoop and the body is small enough.
 644 bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) {
 645 
 646   CountedLoopNode *cl = _head->as_CountedLoop();
 647   assert(cl->is_normal_loop() || cl->is_main_loop(), "");
 648 
 649   if (!cl->is_valid_counted_loop())
 650     return false; // Malformed counted loop
 651 
 652   // Protect against over-unrolling.
 653   // After split at least one iteration will be executed in pre-loop.
 654   if (cl->trip_count() <= (uint)(cl->is_normal_loop() ? 2 : 1)) return false;
 655 
 656   _local_loop_unroll_limit = LoopUnrollLimit;
 657   _local_loop_unroll_factor = 4;
 658   int future_unroll_ct = cl->unrolled_count() * 2;
 659   if (future_unroll_ct > LoopMaxUnroll) return false;
 660 
 661   if (UseSuperWord) {
 662     if (cl->is_reduction_loop() == false) phase->mark_reductions(this);
 663 
 664     // Only attempt slp analysis when user controls do not prohibit it
 665     if (LoopMaxUnroll > _local_loop_unroll_factor) {
 666       // Once policy_slp_analysis succeeds, mark the loop with the
 667       // maximal unroll factor so that we minimize analysis passes
 668       if (cl->has_passed_slp() == false) {
 669         if (policy_slp_analysis(cl, phase)) {
 670           if (_local_loop_unroll_factor > 4) {
 671             cl->mark_passed_slp();
 672             cl->set_slp_max_unroll(_local_loop_unroll_factor);
 673           }
 674         }
 675       }
 676 
 677       if (cl->has_passed_slp()) {
 678         int slp_max_unroll_factor = cl->slp_max_unroll();
 679         if ((slp_max_unroll_factor > 4) &&
 680             (slp_max_unroll_factor >= future_unroll_ct)) {
 681           int new_limit = cl->node_count_before_unroll() * slp_max_unroll_factor;
 682           if (new_limit > LoopUnrollLimit) {
 683 #ifndef PRODUCT
 684             if (TraceSuperWordLoopUnrollAnalysis) {
 685               tty->print_cr("slp analysis is applying unroll limit  %d, the original limit was %d\n",
 686                             new_limit, _local_loop_unroll_limit);
 687             }
 688 #endif
 689             _local_loop_unroll_limit = new_limit;
 690           }
 691         }
 692       }
 693     }
 694   }
 695 
 696   // Check for initial stride being a small enough constant
 697   if (abs(cl->stride_con()) > (1<<2)*future_unroll_ct) return false;
 698 
 699   // Don't unroll if the next round of unrolling would push us
 700   // over the expected trip count of the loop.  One is subtracted
 701   // from the expected trip count because the pre-loop normally
 702   // executes 1 iteration.
 703   if (UnrollLimitForProfileCheck > 0 &&
 704       cl->profile_trip_cnt() != COUNT_UNKNOWN &&
 705       future_unroll_ct        > UnrollLimitForProfileCheck &&
 706       (float)future_unroll_ct > cl->profile_trip_cnt() - 1.0) {
 707     return false;
 708   }
 709 
 710   // When unroll count is greater than LoopUnrollMin, don't unroll if:
 711   //   the residual iterations are more than 10% of the trip count
 712   //   and rounds of "unroll,optimize" are not making significant progress
 713   //   Progress defined as current size less than 20% larger than previous size.
 714   if (UseSuperWord && cl->node_count_before_unroll() > 0 &&
 715       future_unroll_ct > LoopUnrollMin &&


 769       case Op_StrIndexOf:
 770       case Op_EncodeISOArray:
 771       case Op_AryEq: {
 772         // Do not unroll a loop with String intrinsics code.
 773         // String intrinsics are large and have loops.
 774         return false;
 775       }
 776 #if INCLUDE_RTM_OPT
 777       case Op_FastLock:
 778       case Op_FastUnlock: {
 779         // Don't unroll RTM locking code because it is large.
 780         if (UseRTMLocking) {
 781           return false;
 782         }
 783       }
 784 #endif
 785     } // switch
 786   }
 787 
 788   // Check for being too big
 789   if (body_size > (uint)_local_loop_unroll_limit) {
 790     if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true;
 791     // Normal case: loop too big
 792     return false;
 793   }
 794 
 795   // Unroll once!  (Each trip will soon do double iterations)
 796   return true;
 797 }
 798 
 799 bool IdealLoopTree::policy_slp_analysis( CountedLoopNode *cl, PhaseIdealLoop *phase ) {
 800   // SLP analysis
 801   bool not_slp = false;
 802 
 803   // Enable this functionality target by target as needed
 804   if (SuperWordLoopUnrollAnalysis) {
 805     SuperWord sw(phase);
 806     sw.transform_loop(this, false);
 807 
 808     // If the loop is slp canonical analyze it
 809     if (sw.early_return() == false) {
 810       Arena *a = Thread::current()->resource_area();
 811       int max_vector = Matcher::max_vector_size(T_INT);
 812       size_t ignored_size = _body.size()*sizeof(int*);
 813       int *ignored_loop_nodes = (int*)a->Amalloc_D(ignored_size);
 814       Node_Stack nstack((int)ignored_size);
 815       Node *cl_exit = cl->loopexit();
 816 
 817       // First clear the entries
 818       for (uint i = 0; i < _body.size(); i++) {
 819         ignored_loop_nodes[i] = -1;
 820       }
 821 
 822       // Process the loop, some/all of the stack entries will not be in order, ergo
 823       // need to preprocess the ignored initial state before we process the loop
 824       for (uint i = 0; i < _body.size(); i++) {
 825         Node* n = _body.at(i);
 826         if (n == cl->incr() ||
 827             n->is_reduction() ||
 828             n->is_AddP() ||
 829             n->is_Cmp() ||
 830             n->is_IfTrue() ||
 831             n->is_CountedLoop() ||
 832             (n == cl_exit)) {
 833           ignored_loop_nodes[i] = n->_idx;
 834           continue;
 835         }
 836 
 837         if (n->is_If()) {
 838           IfNode *iff = n->as_If();
 839           if (iff->_fcnt != COUNT_UNKNOWN && iff->_prob != PROB_UNKNOWN) {
 840             if (is_loop_exit(iff)) {
 841               ignored_loop_nodes[i] = n->_idx;
 842               continue;
 843             }
 844           }
 845         }
 846 
 847         if (n->is_Phi() && (n->bottom_type() == Type::MEMORY)) {
 848           Node* n_tail = n->in(LoopNode::LoopBackControl);
 849           if (n_tail != n->in(LoopNode::EntryControl)) {
 850             if (!n_tail->is_Mem()) {
 851               not_slp = true;
 852               break;
 853             }
 854           }
 855         }
 856 
 857         // This must happen after check of phi/if
 858         if (n->is_Phi() || n->is_If()) {
 859           ignored_loop_nodes[i] = n->_idx;
 860           continue;
 861         }
 862 
 863         if (n->is_LoadStore() || n->is_MergeMem() ||
 864             (n->is_Proj() && !n->as_Proj()->is_CFG())) {
 865           not_slp = true;
 866           break;
 867         }
 868 
 869         if (n->is_Mem()) {
 870           Node* adr = n->in(MemNode::Address);
 871           Node* n_ctrl = phase->get_ctrl(adr);
 872 
 873           // save a queue of post process nodes
 874           if (n_ctrl != NULL && is_member(phase->get_loop(n_ctrl))) {
 875             MemNode* current = n->as_Mem();
 876             BasicType bt = current->memory_type();
 877             if (is_java_primitive(bt) == false) {
 878               ignored_loop_nodes[i] = n->_idx;
 879               continue;
 880             }
 881 
 882             // Process the memory expression
 883             int stack_idx = 0;
 884             bool have_side_effects = true;
 885             if (adr->is_AddP() == false) {
 886               nstack.push(adr, stack_idx++);
 887             } else {
 888               // Mark the components of the memory operation in nstack
 889               SWPointer p1(current, &sw, &nstack, true);
 890               have_side_effects = p1.node_stack()->is_nonempty();
 891             }
 892 
 893             // Process the pointer stack
 894             while (have_side_effects) {
 895               Node* pointer_node = nstack.node();
 896               for (uint j = 0; j < _body.size(); j++) {
 897                 Node* cur_node = _body.at(j);
 898                 if (cur_node == pointer_node) {
 899                   ignored_loop_nodes[j] = cur_node->_idx;
 900                   break;
 901                 }
 902               }
 903               nstack.pop();
 904               have_side_effects = nstack.is_nonempty();
 905             }
 906 
 907             // Cleanup
 908             nstack.clear();
 909           }
 910         }
 911       }
 912 
 913       if (not_slp == false) {
 914         // Now we try to find the maximum supported consistent vector which the machine
 915         // description can use
 916         for (uint i = 0; i < _body.size(); i++) {
 917           if (ignored_loop_nodes[i] != -1) continue;
 918 
 919           BasicType bt;
 920           Node* n = _body.at(i);
 921           if (n->is_Store()) {
 922             bt = n->as_Mem()->memory_type();
 923           } else {
 924             bt = n->bottom_type()->basic_type();
 925           }
 926 
 927           int cur_max_vector = Matcher::max_vector_size(bt);
 928 
 929           // If a max vector exists which is not larger than _local_loop_unroll_factor
 930           // stop looking, we already have the max vector to map to.
 931           if (cur_max_vector <= _local_loop_unroll_factor) {
 932             not_slp = true;
 933 #ifndef PRODUCT
 934             if (TraceSuperWordLoopUnrollAnalysis) {
 935               tty->print_cr("slp analysis fails: unroll limit equals max vector\n");
 936             }
 937 #endif
 938             break;
 939           }
 940 
 941           // Map the maximal common vector
 942           if (VectorNode::implemented(n->Opcode(), cur_max_vector, bt)) {
 943             if (cur_max_vector < max_vector) {
 944               max_vector = cur_max_vector;
 945             }
 946           }
 947         }
 948         if (not_slp == false) _local_loop_unroll_factor = max_vector;
 949       }
 950 
 951       if (not_slp) {
 952         // Mark the loop as processed so that we do not try again
 953         cl->mark_passed_slp();
 954         cl->set_slp_max_unroll(_local_loop_unroll_factor);
 955       }
 956 
 957       // Now clean things up
 958       a->Afree(ignored_loop_nodes, ignored_size);
 959     }
 960   }
 961 
 962   return (not_slp == false);
 963 }
 964 
 965 //------------------------------policy_align-----------------------------------
 966 // Return TRUE or FALSE if the loop should be cache-line aligned.  Gather the
 967 // expression that does the alignment.  Note that only one array base can be
 968 // aligned in a loop (unless the VM guarantees mutual alignment).  Note that
 969 // if we vectorize short memory ops into longer memory ops, we may want to
 970 // increase alignment.
 971 bool IdealLoopTree::policy_align( PhaseIdealLoop *phase ) const {
 972   return false;
 973 }
 974 
 975 //------------------------------policy_range_check-----------------------------
 976 // Return TRUE or FALSE if the loop should be range-check-eliminated.
 977 // Actually we do iteration-splitting, a more powerful form of RCE.
 978 bool IdealLoopTree::policy_range_check( PhaseIdealLoop *phase ) const {
 979   if (!RangeCheckElimination) return false;
 980 
 981   CountedLoopNode *cl = _head->as_CountedLoop();
 982   // If we unrolled with no intention of doing RCE and we later
 983   // changed our minds, we got no pre-loop.  Either we need to
 984   // make a new pre-loop, or we gotta disallow RCE.


1738   }
1739 
1740   Node* trip_phi = loop_head->phi();
1741   for (DUIterator_Fast imax, i = loop_head->fast_outs(imax); i < imax; i++) {
1742     Node* phi = loop_head->fast_out(i);
1743     if (phi->is_Phi() && phi->outcnt() > 0 && phi != trip_phi) {
1744       // For definitions which are loop inclusive and not tripcounts.
1745       Node* def_node = phi->in(LoopNode::LoopBackControl);
1746 
1747       if (def_node != NULL) {
1748         Node* n_ctrl = get_ctrl(def_node);
1749         if (n_ctrl != NULL && loop->is_member(get_loop(n_ctrl))) {
1750           // Now test it to see if it fits the standard pattern for a reduction operator.
1751           int opc = def_node->Opcode();
1752           if (opc != ReductionNode::opcode(opc, def_node->bottom_type()->basic_type())) {
1753             if (!def_node->is_reduction()) { // Not marked yet
1754               // To be a reduction, the arithmetic node must have the phi as input and provide a def to it
1755               for (unsigned j = 1; j < def_node->req(); j++) {
1756                 Node* in = def_node->in(j);
1757                 if (in == phi) {
1758                   loop_head->mark_has_reductions();
1759                   def_node->add_flag(Node::Flag_is_reduction);
1760                   break;
1761                 }
1762               }
1763             }
1764           }
1765         }
1766       }
1767     }
1768   }
1769 }
1770 
1771 //------------------------------dominates_backedge---------------------------------
1772 // Returns true if ctrl is executed on every complete iteration
1773 bool IdealLoopTree::dominates_backedge(Node* ctrl) {
1774   assert(ctrl->is_CFG(), "must be control");
1775   Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
1776   return _phase->dom_lca_internal(ctrl, backedge) == ctrl;
1777 }
1778 


2589 
2590   // If we have any of these conditions (RCE, alignment, unrolling) met, then
2591   // we switch to the pre-/main-/post-loop model.  This model also covers
2592   // peeling.
2593   if (should_rce || should_align || should_unroll) {
2594     if (cl->is_normal_loop())  // Convert to 'pre/main/post' loops
2595       phase->insert_pre_post_loops(this,old_new, !may_rce_align);
2596 
2597     // Adjust the pre- and main-loop limits to let the pre and post loops run
2598     // with full checks, but the main-loop with no checks.  Remove said
2599     // checks from the main body.
2600     if (should_rce)
2601       phase->do_range_check(this,old_new);
2602 
2603     // Double loop body for unrolling.  Adjust the minimum-trip test (will do
2604     // twice as many iterations as before) and the main body limit (only do
2605     // an even number of trips).  If we are peeling, we might enable some RCE
2606     // and we'd rather unroll the post-RCE'd loop SO... do not unroll if
2607     // peeling.
2608     if (should_unroll && !should_peel) {

2609       phase->do_unroll(this, old_new, true);
2610     }
2611 
2612     // Adjust the pre-loop limits to align the main body
2613     // iterations.
2614     if (should_align)
2615       Unimplemented();
2616 
2617   } else {                      // Else we have an unchanged counted loop
2618     if (should_peel)           // Might want to peel but do nothing else
2619       phase->do_peeling(this,old_new);
2620   }
2621   return true;
2622 }
2623 
2624 
2625 //=============================================================================
2626 //------------------------------iteration_split--------------------------------
2627 bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new ) {
2628   // Recursively iteration split nested loops


< prev index next >