Skip to content

Commit caceaba

Browse files
committed
8286177: C2: "failed: non-reduction loop contains reduction nodes" assert failure
Backport-of: 6458a56e60472fb2fbe8fa60bbc856dc95f50f07
1 parent dd7ab3d commit caceaba

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

src/hotspot/share/opto/superword.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,11 @@ bool SuperWord::output() {
24102410
return false;
24112411
}
24122412

2413+
// Check that the loop to be vectorized does not have inconsistent reduction
2414+
// information, which would likely lead to a miscompilation.
2415+
assert(!lpt()->has_reduction_nodes() || cl->is_reduction_loop(),
2416+
"non-reduction loop contains reduction nodes");
2417+
24132418
#ifndef PRODUCT
24142419
if (TraceLoopOpts) {
24152420
tty->print("SuperWord::output ");
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. 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 8286177
27+
* @summary Test that inconsistent reduction node-loop state does not trigger
28+
* assertion failures when the inconsistency does not lead to a
29+
* miscompilation.
30+
* @run main/othervm -Xbatch compiler.loopopts.superword.TestHoistedReductionNode
31+
*/
32+
package compiler.loopopts.superword;
33+
34+
public class TestHoistedReductionNode {
35+
36+
static boolean b = true;
37+
38+
static int test() {
39+
int acc = 0;
40+
int i = 0;
41+
do {
42+
int j = 0;
43+
do {
44+
if (b) {
45+
acc += j;
46+
}
47+
j++;
48+
} while (j < 5);
49+
i++;
50+
} while (i < 100);
51+
return acc;
52+
53+
}
54+
55+
public static void main(String[] args) {
56+
for (int i = 0; i < 10_000; i++) {
57+
test();
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)