# HG changeset patch # User roland # Date 1521688500 25200 # Node ID 45675142a18a7888882cc55c32326682dfd1b189 # Parent 8d02d496e785732a912b86a9ed08405ac17aeb6e 8199784: PhaseIdealLoop::place_near_use() might return wrong control with loop strip mining Reviewed-by: kvn diff -r 8d02d496e785 -r 45675142a18a src/hotspot/share/opto/loopopts.cpp --- a/src/hotspot/share/opto/loopopts.cpp Tue Mar 20 22:54:02 2018 +0800 +++ b/src/hotspot/share/opto/loopopts.cpp Wed Mar 21 20:15:00 2018 -0700 @@ -1029,11 +1029,18 @@ //------------------------------place_near_use--------------------------------- // Place some computation next to use but not inside inner loops. // For inner loop uses move it to the preheader area. -Node *PhaseIdealLoop::place_near_use( Node *useblock ) const { +Node *PhaseIdealLoop::place_near_use(Node *useblock) const { IdealLoopTree *u_loop = get_loop( useblock ); - return (u_loop->_irreducible || u_loop->_child) - ? useblock - : u_loop->_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl); + if (u_loop->_irreducible) { + return useblock; + } + if (u_loop->_child) { + if (useblock == u_loop->_head && u_loop->_head->is_OuterStripMinedLoop()) { + return u_loop->_head->in(LoopNode::EntryControl); + } + return useblock; + } + return u_loop->_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl); }