8199784: PhaseIdealLoop::place_near_use() might return wrong control with loop strip mining
authorroland
Wed, 21 Mar 2018 20:15:00 -0700
changeset 49482 45675142a18a
parent 49481 8d02d496e785
child 49483 d374b1634589
8199784: PhaseIdealLoop::place_near_use() might return wrong control with loop strip mining Reviewed-by: kvn
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);
 }