1.1 --- a/src/share/vm/opto/superword.cpp Tue Feb 04 17:38:01 2020 +0800 1.2 +++ b/src/share/vm/opto/superword.cpp Tue Feb 04 18:13:14 2020 +0800 1.3 @@ -448,6 +448,7 @@ 1.4 return true; // no induction variable 1.5 } 1.6 CountedLoopEndNode* pre_end = get_pre_loop_end(lp()->as_CountedLoop()); 1.7 + assert(pre_end != NULL, "we must have a correct pre-loop"); 1.8 assert(pre_end->stride_is_con(), "pre loop stride is constant"); 1.9 int preloop_stride = pre_end->stride_con(); 1.10 1.11 @@ -2052,7 +2053,7 @@ 1.12 CountedLoopNode *main_head = lp()->as_CountedLoop(); 1.13 assert(main_head->is_main_loop(), ""); 1.14 CountedLoopEndNode* pre_end = get_pre_loop_end(main_head); 1.15 - assert(pre_end != NULL, ""); 1.16 + assert(pre_end != NULL, "we must have a correct pre-loop"); 1.17 Node *pre_opaq1 = pre_end->limit(); 1.18 assert(pre_opaq1->Opcode() == Op_Opaque1, ""); 1.19 Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1; 1.20 @@ -2207,16 +2208,27 @@ 1.21 1.22 //----------------------------get_pre_loop_end--------------------------- 1.23 // Find pre loop end from main loop. Returns null if none. 1.24 -CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode *cl) { 1.25 - Node *ctrl = cl->in(LoopNode::EntryControl); 1.26 +CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode* cl) { 1.27 + Node* ctrl = cl->in(LoopNode::EntryControl); 1.28 if (!ctrl->is_IfTrue() && !ctrl->is_IfFalse()) return NULL; 1.29 - Node *iffm = ctrl->in(0); 1.30 + Node* iffm = ctrl->in(0); 1.31 if (!iffm->is_If()) return NULL; 1.32 - Node *p_f = iffm->in(0); 1.33 + Node* bolzm = iffm->in(1); 1.34 + if (!bolzm->is_Bool()) return NULL; 1.35 + Node* cmpzm = bolzm->in(1); 1.36 + if (!cmpzm->is_Cmp()) return NULL; 1.37 + Node* opqzm = cmpzm->in(2); 1.38 + // Can not optimize a loop if zero-trip Opaque1 node is optimized 1.39 + // away and then another round of loop opts attempted. 1.40 + if (opqzm->Opcode() != Op_Opaque1) { 1.41 + return NULL; 1.42 + } 1.43 + Node* p_f = iffm->in(0); 1.44 if (!p_f->is_IfFalse()) return NULL; 1.45 if (!p_f->in(0)->is_CountedLoopEnd()) return NULL; 1.46 - CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd(); 1.47 - if (!pre_end->loopnode()->is_pre_loop()) return NULL; 1.48 + CountedLoopEndNode* pre_end = p_f->in(0)->as_CountedLoopEnd(); 1.49 + CountedLoopNode* loop_node = pre_end->loopnode(); 1.50 + if (loop_node == NULL || !loop_node->is_pre_loop()) return NULL; 1.51 return pre_end; 1.52 } 1.53