src/hotspot/share/opto/loopnode.cpp
changeset 55307 ed12027517c0
parent 55150 ba171f871932
child 55559 38c73e24fa7b
equal deleted inserted replaced
55306:ea43db53de91 55307:ed12027517c0
   976         }
   976         }
   977         wq.clear();
   977         wq.clear();
   978         wq.push(u);
   978         wq.push(u);
   979         bool found_sfpt = false;
   979         bool found_sfpt = false;
   980         for (uint next = 0; next < wq.size() && !found_sfpt; next++) {
   980         for (uint next = 0; next < wq.size() && !found_sfpt; next++) {
   981           Node *n = wq.at(next);
   981           Node* n = wq.at(next);
   982           for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax && !found_sfpt; i++) {
   982           for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax && !found_sfpt; i++) {
   983             Node* u = n->fast_out(i);
   983             Node* u = n->fast_out(i);
   984             if (u == sfpt) {
   984             if (u == sfpt) {
   985               found_sfpt = true;
   985               found_sfpt = true;
   986             }
   986             }
   990           }
   990           }
   991         }
   991         }
   992         assert(found_sfpt, "no node in loop that's not input to safepoint");
   992         assert(found_sfpt, "no node in loop that's not input to safepoint");
   993       }
   993       }
   994     }
   994     }
       
   995 
       
   996     if (UseZGC && !inner_out->in(0)->is_CountedLoopEnd()) {
       
   997       // In some very special cases there can be a load that has no other uses than the
       
   998       // counted loop safepoint. Then its loadbarrier will be placed between the inner
       
   999       // loop exit and the safepoint. This is very rare
       
  1000 
       
  1001       Node* ifnode = inner_out->in(1)->in(0);
       
  1002       // Region->IfTrue->If == Region->Iffalse->If
       
  1003       if (ifnode == inner_out->in(2)->in(0)) {
       
  1004         inner_out = ifnode->in(0);
       
  1005       }
       
  1006     }
       
  1007 
   995     CountedLoopEndNode* cle = inner_out->in(0)->as_CountedLoopEnd();
  1008     CountedLoopEndNode* cle = inner_out->in(0)->as_CountedLoopEnd();
   996     assert(cle == inner->loopexit_or_null(), "mismatch");
  1009     assert(cle == inner->loopexit_or_null(), "mismatch");
   997     bool has_skeleton = outer_le->in(1)->bottom_type()->singleton() && outer_le->in(1)->bottom_type()->is_int()->get_con() == 0;
  1010     bool has_skeleton = outer_le->in(1)->bottom_type()->singleton() && outer_le->in(1)->bottom_type()->is_int()->get_con() == 0;
   998     if (has_skeleton) {
  1011     if (has_skeleton) {
   999       assert(expect_skeleton == 1 || expect_skeleton == -1, "unexpected skeleton node");
  1012       assert(expect_skeleton == 1 || expect_skeleton == -1, "unexpected skeleton node");
  2759 //=============================================================================
  2772 //=============================================================================
  2760 //----------------------------build_and_optimize-------------------------------
  2773 //----------------------------build_and_optimize-------------------------------
  2761 // Create a PhaseLoop.  Build the ideal Loop tree.  Map each Ideal Node to
  2774 // Create a PhaseLoop.  Build the ideal Loop tree.  Map each Ideal Node to
  2762 // its corresponding LoopNode.  If 'optimize' is true, do some loop cleanups.
  2775 // its corresponding LoopNode.  If 'optimize' is true, do some loop cleanups.
  2763 void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
  2776 void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
  2764   bool do_split_ifs = (mode == LoopOptsDefault || mode == LoopOptsLastRound);
  2777   bool do_split_ifs = (mode == LoopOptsDefault);
  2765   bool skip_loop_opts = (mode == LoopOptsNone);
  2778   bool skip_loop_opts = (mode == LoopOptsNone);
  2766 
  2779 
  2767   int old_progress = C->major_progress();
  2780   int old_progress = C->major_progress();
  2768   uint orig_worklist_size = _igvn._worklist.size();
  2781   uint orig_worklist_size = _igvn._worklist.size();
  2769 
  2782 
  2919   NOT_PRODUCT( C->verify_graph_edges(); )
  2932   NOT_PRODUCT( C->verify_graph_edges(); )
  2920   worklist.push( C->top() );
  2933   worklist.push( C->top() );
  2921   build_loop_late( visited, worklist, nstack );
  2934   build_loop_late( visited, worklist, nstack );
  2922 
  2935 
  2923   if (_verify_only) {
  2936   if (_verify_only) {
  2924     // restore major progress flag
  2937     C->restore_major_progress(old_progress);
  2925     for (int i = 0; i < old_progress; i++)
       
  2926       C->set_major_progress();
       
  2927     assert(C->unique() == unique, "verification mode made Nodes? ? ?");
  2938     assert(C->unique() == unique, "verification mode made Nodes? ? ?");
  2928     assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything");
  2939     assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything");
  2929     return;
  2940     return;
  2930   }
  2941   }
  2931 
  2942 
  2965   }
  2976   }
  2966 #endif
  2977 #endif
  2967 
  2978 
  2968   if (skip_loop_opts) {
  2979   if (skip_loop_opts) {
  2969     // restore major progress flag
  2980     // restore major progress flag
  2970     for (int i = 0; i < old_progress; i++) {
  2981     C->restore_major_progress(old_progress);
  2971       C->set_major_progress();
       
  2972     }
       
  2973 
  2982 
  2974     // Cleanup any modified bits
  2983     // Cleanup any modified bits
  2975     _igvn.optimize();
  2984     _igvn.optimize();
  2976 
  2985 
  2977     if (C->log() != NULL) {
  2986     if (C->log() != NULL) {
  3016 
  3025 
  3017   // Check for aggressive application of split-if and other transforms
  3026   // Check for aggressive application of split-if and other transforms
  3018   // that require basic-block info (like cloning through Phi's)
  3027   // that require basic-block info (like cloning through Phi's)
  3019   if( SplitIfBlocks && do_split_ifs ) {
  3028   if( SplitIfBlocks && do_split_ifs ) {
  3020     visited.Clear();
  3029     visited.Clear();
  3021     split_if_with_blocks( visited, nstack, mode == LoopOptsLastRound );
  3030     split_if_with_blocks( visited, nstack);
  3022     NOT_PRODUCT( if( VerifyLoopOptimizations ) verify(); );
  3031     NOT_PRODUCT( if( VerifyLoopOptimizations ) verify(); );
  3023     if (mode == LoopOptsLastRound) {
       
  3024       C->set_major_progress();
       
  3025     }
       
  3026   }
  3032   }
  3027 
  3033 
  3028   if (!C->major_progress() && do_expensive_nodes && process_expensive_nodes()) {
  3034   if (!C->major_progress() && do_expensive_nodes && process_expensive_nodes()) {
  3029     C->set_major_progress();
  3035     C->set_major_progress();
  3030   }
  3036   }
  3155   assert( fail == 0, "verify loops failed" );
  3161   assert( fail == 0, "verify loops failed" );
  3156   // Verify loop structure is the same
  3162   // Verify loop structure is the same
  3157   _ltree_root->verify_tree(loop_verify._ltree_root, NULL);
  3163   _ltree_root->verify_tree(loop_verify._ltree_root, NULL);
  3158   // Reset major-progress.  It was cleared by creating a verify version of
  3164   // Reset major-progress.  It was cleared by creating a verify version of
  3159   // PhaseIdealLoop.
  3165   // PhaseIdealLoop.
  3160   for( int i=0; i<old_progress; i++ )
  3166   C->restore_major_progress(old_progress);
  3161     C->set_major_progress();
       
  3162 }
  3167 }
  3163 
  3168 
  3164 //------------------------------verify_compare---------------------------------
  3169 //------------------------------verify_compare---------------------------------
  3165 // Make sure me and the given PhaseIdealLoop agree on key data structures
  3170 // Make sure me and the given PhaseIdealLoop agree on key data structures
  3166 void PhaseIdealLoop::verify_compare( Node *n, const PhaseIdealLoop *loop_verify, VectorSet &visited ) const {
  3171 void PhaseIdealLoop::verify_compare( Node *n, const PhaseIdealLoop *loop_verify, VectorSet &visited ) const {
  4286     case Op_LoadNKlass:
  4291     case Op_LoadNKlass:
  4287     case Op_LoadL:
  4292     case Op_LoadL:
  4288     case Op_LoadS:
  4293     case Op_LoadS:
  4289     case Op_LoadP:
  4294     case Op_LoadP:
  4290     case Op_LoadBarrierSlowReg:
  4295     case Op_LoadBarrierSlowReg:
  4291     case Op_LoadBarrierWeakSlowReg:
       
  4292     case Op_LoadN:
  4296     case Op_LoadN:
  4293     case Op_LoadRange:
  4297     case Op_LoadRange:
  4294     case Op_LoadD_unaligned:
  4298     case Op_LoadD_unaligned:
  4295     case Op_LoadL_unaligned:
  4299     case Op_LoadL_unaligned:
  4296     case Op_StrComp:            // Does a bunch of load-like effects
  4300     case Op_StrComp:            // Does a bunch of load-like effects