changeset 48529:efa7f1a283e4

8196296: Lucene test crashes C2 compilation Summary: Prevent merging of back to back ifs if one is a counted loop end. Reviewed-by: kvn, thartmann
author roland
date Tue, 30 Jan 2018 09:08:44 +0100
parents f8d9bedbacf2
children edd2ac895ae1
files src/hotspot/share/opto/loopnode.cpp src/hotspot/share/opto/loopopts.cpp test/hotspot/jtreg/compiler/loopopts/TestStripMinedBackToBackIfs.java
diffstat 3 files changed, 58 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/loopnode.cpp	Fri Jan 26 13:13:19 2018 -0800
+++ b/src/hotspot/share/opto/loopnode.cpp	Tue Jan 30 09:08:44 2018 +0100
@@ -1260,6 +1260,10 @@
   assert(inner_cl->is_strip_mined(), "inner loop should be strip mined");
   Node* inner_iv_phi = inner_cl->phi();
   if (inner_iv_phi == NULL) {
+    IfNode* outer_le = outer_loop_end();
+    Node* iff = igvn->transform(new IfNode(outer_le->in(0), outer_le->in(1), outer_le->_prob, outer_le->_fcnt));
+    igvn->replace_node(outer_le, iff);
+    inner_cl->clear_strip_mined();
     return;
   }
   CountedLoopEndNode* inner_cle = inner_cl->loopexit();
--- a/src/hotspot/share/opto/loopopts.cpp	Fri Jan 26 13:13:19 2018 -0800
+++ b/src/hotspot/share/opto/loopopts.cpp	Tue Jan 30 09:08:44 2018 +0100
@@ -1036,7 +1036,7 @@
 
 
 bool PhaseIdealLoop::identical_backtoback_ifs(Node *n) {
-  if (!n->is_If()) {
+  if (!n->is_If() || n->is_CountedLoopEnd()) {
     return false;
   }
   if (!n->in(0)->is_Region()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopopts/TestStripMinedBackToBackIfs.java	Tue Jan 30 09:08:44 2018 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2018, 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 8196296
+ * @summary Bad graph when unrolled loop bounds conflicts with range checks
+ *
+ * @run main/othervm -XX:-BackgroundCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=0 TestStripMinedBackToBackIfs
+ *
+ */
+
+
+public class TestStripMinedBackToBackIfs {
+    public static void main(String[] args) {
+        for (int i = 0; i < 20_000; i++) {
+            test(100);
+        }
+    }
+
+    private static double test(int limit) {
+        double v = 1;
+        for (int i = 0; i < limit; i++) {
+            v = v * 4;
+            // We don't want this test to be merged with identical
+            // loop end test
+            if (i+1 < limit) {
+                v = v * 2;
+            }
+        }
+        return v;
+    }
+}