Skip to content

Commit 72a45dd

Browse files
committed
8341834: C2 compilation fails with "bad AD file" due to Replicate
Reviewed-by: kvn, epeter
1 parent 57c3bb6 commit 72a45dd

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/hotspot/share/opto/superwordVTransformBuilder.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,13 @@ VTransformNode* SuperWordVTransformBuilder::get_or_make_vtnode_vector_input_at_i
228228
return shift_count;
229229
} else {
230230
// Replicate the scalar same_input to every vector element.
231-
BasicType element_type = _vloop_analyzer.types().velt_basic_type(p0);
231+
// In some rare case, p0 is Convert node such as a ConvL2I: all
232+
// ConvL2I nodes in the pack only differ in their types.
233+
// velt_basic_type(p0) is the output type of the pack. In the
234+
// case of a ConvL2I, it can be int or some narrower type such
235+
// as short etc. But given we replicate the input of the Convert
236+
// node, we have to use the input type instead.
237+
BasicType element_type = p0->is_Convert() ? p0->in(1)->bottom_type()->basic_type() : _vloop_analyzer.types().velt_basic_type(p0);
232238
if (index == 2 && VectorNode::is_scalar_rotate(p0) && element_type == T_LONG) {
233239
// Scalar rotate has int rotation value, but the scalar rotate expects longs.
234240
assert(same_input->bottom_type()->isa_int(), "scalar rotate expects int rotation");
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2024, 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 8341834
27+
* @summary C2 compilation fails with "bad AD file" due to Replicate
28+
* @run main/othervm -XX:CompileCommand=compileonly,TestReplicateAtConv::test -Xcomp TestReplicateAtConv
29+
*/
30+
31+
public class TestReplicateAtConv {
32+
public static long val = 0;
33+
34+
public static void test() {
35+
int array[] = new int[500];
36+
37+
for (int i = 0; i < 100; i++) {
38+
for (long l = 100; l > i; l--) {
39+
val = 42 + (l + i);
40+
array[(int)l] = (int)l - (int)val;
41+
}
42+
}
43+
}
44+
45+
public static void main(String[] args) {
46+
test();
47+
}
48+
}

0 commit comments

Comments
 (0)