Skip to content

Commit 38fdbd4

Browse files
committed
8289127: Apache Lucene triggers: DEBUG MESSAGE: duplicated predicate failed which is impossible
Backport-of: 4f3f74c14121d0a80f0dcf1d593b4cf1c3e4a64c
1 parent e650bdc commit 38fdbd4

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

src/hotspot/share/opto/loopTransform.cpp

+34-3
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,7 @@ static bool skeleton_follow_inputs(Node* n, int op) {
13111311
op == Op_OrL ||
13121312
op == Op_RShiftL ||
13131313
op == Op_LShiftL ||
1314+
op == Op_LShiftI ||
13141315
op == Op_AddL ||
13151316
op == Op_AddI ||
13161317
op == Op_MulL ||
@@ -1325,6 +1326,8 @@ bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
13251326
ResourceMark rm;
13261327
Unique_Node_List wq;
13271328
wq.push(iff->in(1)->in(1));
1329+
uint init = 0;
1330+
uint stride = 0;
13281331
for (uint i = 0; i < wq.size(); i++) {
13291332
Node* n = wq.at(i);
13301333
int op = n->Opcode();
@@ -1337,11 +1340,39 @@ bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
13371340
}
13381341
continue;
13391342
}
1340-
if (n->is_Opaque1()) {
1341-
return true;
1343+
if (n->Opcode() == Op_OpaqueLoopInit) {
1344+
init++;
1345+
} else if (n->Opcode() == Op_OpaqueLoopStride) {
1346+
stride++;
13421347
}
13431348
}
1344-
return false;
1349+
#ifdef ASSERT
1350+
wq.clear();
1351+
wq.push(iff->in(1)->in(1));
1352+
uint verif_init = 0;
1353+
uint verif_stride = 0;
1354+
for (uint i = 0; i < wq.size(); i++) {
1355+
Node* n = wq.at(i);
1356+
int op = n->Opcode();
1357+
if (!n->is_CFG()) {
1358+
if (n->Opcode() == Op_OpaqueLoopInit) {
1359+
verif_init++;
1360+
} else if (n->Opcode() == Op_OpaqueLoopStride) {
1361+
verif_stride++;
1362+
} else {
1363+
for (uint j = 1; j < n->req(); j++) {
1364+
Node* m = n->in(j);
1365+
if (m != NULL) {
1366+
wq.push(m);
1367+
}
1368+
}
1369+
}
1370+
}
1371+
}
1372+
assert(init == verif_init && stride == verif_stride, "missed opaque node");
1373+
#endif
1374+
assert(stride == 0 || init != 0, "init should be there every time stride is");
1375+
return init != 0;
13451376
}
13461377

13471378
// Clone the skeleton predicate bool for a main or unswitched loop:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2022, Red Hat, Inc. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8289127
27+
* @summary Apache Lucene triggers: DEBUG MESSAGE: duplicated predicate failed which is impossible
28+
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-TieredCompilation TestMissedOpaqueInPredicate
29+
*/
30+
31+
public class TestMissedOpaqueInPredicate {
32+
public static void main(String[] args) {
33+
long[] tmp = new long[28];
34+
long[] longs = new long[32];
35+
for (int i = 0; i < 20_000; i++) {
36+
test(tmp, longs);
37+
}
38+
}
39+
40+
private static void test(long[] tmp, long[] longs) {
41+
for (int iter = 0, tmpIdx = 0, longsIdx = 28; iter < 4; ++iter, tmpIdx += 7, longsIdx += 1) {
42+
long l0 = tmp[tmpIdx + 0] << 12;
43+
l0 |= tmp[tmpIdx + 1] << 10;
44+
l0 |= tmp[tmpIdx + 2] << 8;
45+
l0 |= tmp[tmpIdx + 3] << 6;
46+
l0 |= tmp[tmpIdx + 4] << 4;
47+
l0 |= tmp[tmpIdx + 5] << 2;
48+
l0 |= tmp[tmpIdx + 6] << 0;
49+
longs[longsIdx + 0] = l0;
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)