8230061: # assert(mode == ControlAroundStripMined && use == sfpt) failed: missed a node
authorroland
Wed, 28 Aug 2019 15:51:03 +0200
changeset 58285 1182ff8929cc
parent 58284 59f7c242ccb8
child 58286 e4d90117c5de
8230061: # assert(mode == ControlAroundStripMined && use == sfpt) failed: missed a node Reviewed-by: thartmann, neliasso
src/hotspot/share/opto/loopopts.cpp
src/hotspot/share/opto/node.cpp
src/hotspot/share/opto/node.hpp
test/hotspot/jtreg/compiler/loopstripmining/DeadNodesInOuterLoopAtLoopCloning.java
--- a/src/hotspot/share/opto/loopopts.cpp	Tue Sep 24 10:16:00 2019 +0100
+++ b/src/hotspot/share/opto/loopopts.cpp	Wed Aug 28 15:51:03 2019 +0200
@@ -1718,7 +1718,7 @@
 #ifdef ASSERT
     if (loop->_head->as_Loop()->is_strip_mined() && outer_loop->is_member(use_loop) && !loop->is_member(use_loop) && old_new[use->_idx] == NULL) {
       Node* sfpt = loop->_head->as_CountedLoop()->outer_safepoint();
-      assert(mode == ControlAroundStripMined && use == sfpt, "missed a node");
+      assert(mode == ControlAroundStripMined && (use == sfpt || !use->is_reachable_from_root()), "missed a node");
     }
 #endif
     if (!loop->is_member(use_loop) && !outer_loop->is_member(use_loop) && (!old->is_CFG() || !use->is_CFG())) {
--- a/src/hotspot/share/opto/node.cpp	Tue Sep 24 10:16:00 2019 +0100
+++ b/src/hotspot/share/opto/node.cpp	Wed Aug 28 15:51:03 2019 +0200
@@ -704,9 +704,26 @@
   dump();
   return true;
 }
+
+bool Node::is_reachable_from_root() const {
+  ResourceMark rm;
+  Unique_Node_List wq;
+  wq.push((Node*)this);
+  RootNode* root = Compile::current()->root();
+  for (uint i = 0; i < wq.size(); i++) {
+    Node* m = wq.at(i);
+    if (m == root) {
+      return true;
+    }
+    for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
+      Node* u = m->fast_out(j);
+      wq.push(u);
+    }
+  }
+  return false;
+}
 #endif
 
-
 //------------------------------is_unreachable---------------------------------
 bool Node::is_unreachable(PhaseIterGVN &igvn) const {
   assert(!is_Mach(), "doesn't work with MachNodes");
--- a/src/hotspot/share/opto/node.hpp	Tue Sep 24 10:16:00 2019 +0100
+++ b/src/hotspot/share/opto/node.hpp	Wed Aug 28 15:51:03 2019 +0200
@@ -394,6 +394,7 @@
 #ifdef ASSERT
   bool is_dead() const;
 #define is_not_dead(n) ((n) == NULL || !VerifyIterativeGVN || !((n)->is_dead()))
+  bool is_reachable_from_root() const;
 #endif
   // Check whether node has become unreachable
   bool is_unreachable(PhaseIterGVN &igvn) const;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopstripmining/DeadNodesInOuterLoopAtLoopCloning.java	Wed Aug 28 15:51:03 2019 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8230061
+ * @summary loop unrolling breaks when outer strip mined loop contains dead node
+ *
+ * @run main/othervm -Xmx1G DeadNodesInOuterLoopAtLoopCloning
+ *
+ */
+
+public class DeadNodesInOuterLoopAtLoopCloning {
+
+    public static final int N = 400;
+
+    public static long instanceCount=-2288355609708559532L;
+
+    public static double checkSum(double[] a) {
+        double sum = 0;
+        for (int j = 0; j < a.length; j++) {
+            sum += (a[j] / (j + 1) + a[j] % (j + 1));
+        }
+        return sum;
+    }
+
+    public static int iMeth(double d1) {
+
+        int i4=6022, i5=-211, i6=-15841, iArr[]=new int[N];
+        double d2=-8.78129, dArr[]=new double[N];
+
+        i5 = 1;
+        do {
+            i6 = 1;
+            while (++i6 < 5) {
+                i4 = -933;
+                i4 *= i4;
+                dArr[i5 + 1] = i4;
+                i4 -= i4;
+                d2 = 1;
+                do {
+                    iArr[(int)(d2 + 1)] += (int)instanceCount;
+                    try {
+                        i4 = (i4 % -51430);
+                        i4 = (iArr[i6] % 31311);
+                        iArr[i6 + 1] = (24197 / i5);
+                    } catch (ArithmeticException a_e) {}
+                    i4 -= (int)instanceCount;
+                    i4 <<= i5;
+                    i4 &= 12;
+                } while (++d2 < 1);
+            }
+        } while (++i5 < 320);
+        long meth_res = Double.doubleToLongBits(checkSum(dArr));
+        return (int)meth_res;
+    }
+
+    public static void main(String[] strArr) {
+        DeadNodesInOuterLoopAtLoopCloning _instance = new DeadNodesInOuterLoopAtLoopCloning();
+        for (int i = 0; i < 10 * 320; i++ ) {
+            _instance.iMeth(0.8522);
+        }
+    }
+}