src/share/vm/opto/loopTransform.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8148754 Cdiff src/share/vm/opto/loopTransform.cpp

src/share/vm/opto/loopTransform.cpp

Print this page

        

*** 1451,1474 **** Node *stride = loop_head->stride(); Node *opaq = NULL; if (adjust_min_trip) { // If not maximally unrolling, need adjustment // Search for zero-trip guard. ! assert( loop_head->is_main_loop(), "" ); ! assert( ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, "" ); ! Node *iff = ctrl->in(0); ! assert( iff->Opcode() == Op_If, "" ); ! Node *bol = iff->in(1); ! assert( bol->Opcode() == Op_Bool, "" ); ! Node *cmp = bol->in(1); ! assert( cmp->Opcode() == Op_CmpI, "" ); ! opaq = cmp->in(2); ! // Occasionally it's possible for a zero-trip guard Opaque1 node to be ! // optimized away and then another round of loop opts attempted. ! // We can not optimize this particular loop in that case. ! if (opaq->Opcode() != Op_Opaque1) ! return; // Cannot find zero-trip guard! Bail out! // Zero-trip test uses an 'opaque' node which is not shared. assert(opaq->outcnt() == 1 && opaq->in(1) == limit, ""); } C->set_major_progress(); --- 1451,1468 ---- Node *stride = loop_head->stride(); Node *opaq = NULL; if (adjust_min_trip) { // If not maximally unrolling, need adjustment // Search for zero-trip guard. ! ! // Check the shape of the graph at the loop entry. If an inappropriate ! // graph shape is encountered, the compiler bails out loop unrolling; ! // compilation of the method will still succeed. ! if (!is_canonical_main_loop_entry(loop_head)) { ! return; ! } ! opaq = ctrl->in(0)->in(1)->in(1)->in(2); // Zero-trip test uses an 'opaque' node which is not shared. assert(opaq->outcnt() == 1 && opaq->in(1) == limit, ""); } C->set_major_progress();
*** 2107,2117 **** loop->dump_head(); } #endif assert(RangeCheckElimination, ""); CountedLoopNode *cl = loop->_head->as_CountedLoop(); - assert(cl->is_main_loop(), ""); // protect against stride not being a constant if (!cl->stride_is_con()) return; --- 2101,2110 ----
*** 2119,2142 **** Node *trip_counter = cl->phi(); // Find the main loop limit; we will trim it's iterations // to not ever trip end tests Node *main_limit = cl->limit(); // Need to find the main-loop zero-trip guard Node *ctrl = cl->in(LoopNode::EntryControl); - assert(ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, ""); Node *iffm = ctrl->in(0); ! assert(iffm->Opcode() == Op_If, ""); ! Node *bolzm = iffm->in(1); ! assert(bolzm->Opcode() == Op_Bool, ""); ! Node *cmpzm = bolzm->in(1); ! assert(cmpzm->is_Cmp(), ""); ! Node *opqzm = cmpzm->in(2); ! // Can not optimize a loop if zero-trip Opaque1 node is optimized ! // away and then another round of loop opts attempted. ! if (opqzm->Opcode() != Op_Opaque1) ! return; assert(opqzm->in(1) == main_limit, "do not understand situation"); // Find the pre-loop limit; we will expand its iterations to // not ever trip low tests. Node *p_f = iffm->in(0); --- 2112,2132 ---- Node *trip_counter = cl->phi(); // Find the main loop limit; we will trim it's iterations // to not ever trip end tests Node *main_limit = cl->limit(); + // Check graph shape. Cannot optimize a loop if zero-trip + // Opaque1 node is optimized away and then another round + // of loop opts attempted. + if (!is_canonical_main_loop_entry(cl)) { + return; + } + // Need to find the main-loop zero-trip guard Node *ctrl = cl->in(LoopNode::EntryControl); Node *iffm = ctrl->in(0); ! Node *opqzm = iffm->in(1)->in(1)->in(2); assert(opqzm->in(1) == main_limit, "do not understand situation"); // Find the pre-loop limit; we will expand its iterations to // not ever trip low tests. Node *p_f = iffm->in(0);
src/share/vm/opto/loopTransform.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File