Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Jul 18, 2022
2 parents 4a4d8ed + 2677dd6 commit 6cd1c0c
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 4 deletions.
37 changes: 34 additions & 3 deletions src/hotspot/share/opto/loopTransform.cpp
Expand Up @@ -1390,6 +1390,7 @@ static bool skeleton_follow_inputs(Node* n, int op) {
op == Op_OrL ||
op == Op_RShiftL ||
op == Op_LShiftL ||
op == Op_LShiftI ||
op == Op_AddL ||
op == Op_AddI ||
op == Op_MulL ||
Expand All @@ -1404,6 +1405,8 @@ bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
ResourceMark rm;
Unique_Node_List wq;
wq.push(iff->in(1)->in(1));
uint init = 0;
uint stride = 0;
for (uint i = 0; i < wq.size(); i++) {
Node* n = wq.at(i);
int op = n->Opcode();
Expand All @@ -1416,11 +1419,39 @@ bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
}
continue;
}
if (n->is_Opaque1()) {
return true;
if (n->Opcode() == Op_OpaqueLoopInit) {
init++;
} else if (n->Opcode() == Op_OpaqueLoopStride) {
stride++;
}
}
return false;
#ifdef ASSERT
wq.clear();
wq.push(iff->in(1)->in(1));
uint verif_init = 0;
uint verif_stride = 0;
for (uint i = 0; i < wq.size(); i++) {
Node* n = wq.at(i);
int op = n->Opcode();
if (!n->is_CFG()) {
if (n->Opcode() == Op_OpaqueLoopInit) {
verif_init++;
} else if (n->Opcode() == Op_OpaqueLoopStride) {
verif_stride++;
} else {
for (uint j = 1; j < n->req(); j++) {
Node* m = n->in(j);
if (m != NULL) {
wq.push(m);
}
}
}
}
}
assert(init == verif_init && stride == verif_stride, "missed opaque node");
#endif
assert(stride == 0 || init != 0, "init should be there every time stride is");
return init != 0;
}

// Clone the skeleton predicate bool for a main or unswitched loop:
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/opto/superword.cpp
Expand Up @@ -416,7 +416,9 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) {
cl->mark_passed_slp();
}
cl->mark_was_slp();
cl->set_slp_max_unroll(local_loop_unroll_factor);
if (cl->is_main_loop() || cl->is_rce_post_loop()) {
cl->set_slp_max_unroll(local_loop_unroll_factor);
}
}
}

Expand Down
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2022, 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 8289127
* @summary Apache Lucene triggers: DEBUG MESSAGE: duplicated predicate failed which is impossible
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-TieredCompilation TestMissedOpaqueInPredicate
*/

public class TestMissedOpaqueInPredicate {
public static void main(String[] args) {
long[] tmp = new long[28];
long[] longs = new long[32];
for (int i = 0; i < 20_000; i++) {
test(tmp, longs);
}
}

private static void test(long[] tmp, long[] longs) {
for (int iter = 0, tmpIdx = 0, longsIdx = 28; iter < 4; ++iter, tmpIdx += 7, longsIdx += 1) {
long l0 = tmp[tmpIdx + 0] << 12;
l0 |= tmp[tmpIdx + 1] << 10;
l0 |= tmp[tmpIdx + 2] << 8;
l0 |= tmp[tmpIdx + 3] << 6;
l0 |= tmp[tmpIdx + 4] << 4;
l0 |= tmp[tmpIdx + 5] << 2;
l0 |= tmp[tmpIdx + 6] << 0;
longs[longsIdx + 0] = l0;
}
}
}
86 changes: 86 additions & 0 deletions test/hotspot/jtreg/compiler/loopopts/TestUnreachableInnerLoop.java
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2022, Arm Limited. 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 8289954
* @summary C2: Assert failed in PhaseCFG::verify() after JDK-8183390
*
* @run main/othervm -Xcomp -Xbatch
* -XX:CompileOnly=compiler/loopopts/TestUnreachableInnerLoop
* compiler.loopopts.TestUnreachableInnerLoop
*/

package compiler.loopopts;

public class TestUnreachableInnerLoop {

public static int field = 0;
public static int arr[] = new int[500];

public static void fun() {
for (int elem : arr) {
int x = 1, y = 2, z = 3;
int i, j;

// This is a good loop
for (i = 2; i < 63; i++) {
arr[i] = arr[i] + 3592870;
}

// The inner loop looks quite complex but it's unreachable
// code as loop condition "k < 2" never satisfies
for (j = 3; j < 63; j++) {
for (int k = j; k < 2; k++) {
arr[j] <<= k;
try {
x = k / i;
y = j % 6;
arr[k] = 88 % elem;
} catch (ArithmeticException ex) {}
switch (2) {
case 2: {
try {
y = arr[j] % y;
z = x / 2345;
elem = j % -2;
} catch (ArithmeticException ex) {}
break;
}
case 3: {
y = arr[j] / 2;
z -= k;
break;
}
}
arr[100] -= j;
field += k;
}
}
}
}

public static void main(String[] args) {
fun();
}
}

0 comments on commit 6cd1c0c

Please sign in to comment.