8341834: C2 compilation fails with "bad AD file" due to Replicate

Reviewed-by: kvn, epeter
This commit is contained in:
Roland Westrelin 2024-11-06 14:49:30 +00:00
parent 57c3bb6091
commit 72a45ddbad
2 changed files with 55 additions and 1 deletions

View File

@ -228,7 +228,13 @@ VTransformNode* SuperWordVTransformBuilder::get_or_make_vtnode_vector_input_at_i
return shift_count;
} else {
// Replicate the scalar same_input to every vector element.
BasicType element_type = _vloop_analyzer.types().velt_basic_type(p0);
// In some rare case, p0 is Convert node such as a ConvL2I: all
// ConvL2I nodes in the pack only differ in their types.
// velt_basic_type(p0) is the output type of the pack. In the
// case of a ConvL2I, it can be int or some narrower type such
// as short etc. But given we replicate the input of the Convert
// node, we have to use the input type instead.
BasicType element_type = p0->is_Convert() ? p0->in(1)->bottom_type()->basic_type() : _vloop_analyzer.types().velt_basic_type(p0);
if (index == 2 && VectorNode::is_scalar_rotate(p0) && element_type == T_LONG) {
// Scalar rotate has int rotation value, but the scalar rotate expects longs.
assert(same_input->bottom_type()->isa_int(), "scalar rotate expects int rotation");

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, 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 8341834
* @summary C2 compilation fails with "bad AD file" due to Replicate
* @run main/othervm -XX:CompileCommand=compileonly,TestReplicateAtConv::test -Xcomp TestReplicateAtConv
*/
public class TestReplicateAtConv {
public static long val = 0;
public static void test() {
int array[] = new int[500];
for (int i = 0; i < 100; i++) {
for (long l = 100; l > i; l--) {
val = 42 + (l + i);
array[(int)l] = (int)l - (int)val;
}
}
}
public static void main(String[] args) {
test();
}
}