--- old/src/share/vm/opto/loopnode.cpp 2016-03-14 13:22:02.303086200 -0700 +++ new/src/share/vm/opto/loopnode.cpp 2016-03-14 13:22:02.063086200 -0700 @@ -1933,6 +1933,9 @@ if (cl->is_pre_loop ()) tty->print(" pre" ); if (cl->is_main_loop()) tty->print(" main"); if (cl->is_post_loop()) tty->print(" post"); + if (cl->is_vectorized_loop()) tty->print(" vector"); + if (cl->loop_has_range_checks()) tty->print(" rc "); + if (cl->loop_is_multiversioned()) tty->print(" multi "); } if (_has_call) tty->print(" has_call"); if (_has_sfpt) tty->print(" has_sfpt"); @@ -2451,6 +2454,31 @@ for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) { IdealLoopTree* lpt = iter.current(); if (lpt->is_counted()) { + CountedLoopNode *cl = lpt->_head->as_CountedLoop(); + + // Do a late range check detection + has_range_checks(lpt); + + if (PostLoopMultiversioning) { + // Check that the rce'd post loop is encountered first, multiversion after all + // major main loop optimization are concluded + if (cl->is_post_loop() && !cl->loop_has_range_checks() && !C->major_progress()) { + IdealLoopTree *lpt_next = lpt->_next; + if (lpt_next && lpt_next->is_counted()) { + CountedLoopNode *cl = lpt_next->_head->as_CountedLoop(); + has_range_checks(lpt_next); + if (cl->is_post_loop() && cl->loop_has_range_checks()) { + if (!cl->loop_is_multiversioned()) { + if (multi_version_post_loops(lpt, lpt_next) == false) { + // Cause the rce loop to be optimized away if we fail + cl->mark_is_multiversioned(); + poison_rce_post_loop(lpt); + } + } + } + } + } + } sw.transform_loop(lpt, true); } }