8333890: Fatal error in auto-vectorizer with float16 kernel.
Reviewed-by: kvn
This commit is contained in:
parent
02956ab6e1
commit
55fd1ed228
@ -2586,6 +2586,12 @@ const Type* VLoopTypes::container_type(Node* n) const {
|
||||
}
|
||||
const Type* t = _vloop.phase()->igvn().type(n);
|
||||
if (t->basic_type() == T_INT) {
|
||||
// Float to half float conversion may be succeeded by a conversion from
|
||||
// half float to float, in such a case back propagation of narrow type (SHORT)
|
||||
// may not be possible.
|
||||
if (n->Opcode() == Op_ConvF2HF) {
|
||||
return TypeInt::SHORT;
|
||||
}
|
||||
// A narrow type of arithmetic operations will be determined by
|
||||
// propagating the type of memory operations.
|
||||
return TypeInt::INT;
|
||||
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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
|
||||
* @summary Test Float16 vector conversion chain.
|
||||
* @requires vm.compiler2.enabled
|
||||
* @library /test/lib /
|
||||
* @run driver compiler.vectorization.TestFloat16VectorConvChain
|
||||
*/
|
||||
|
||||
package compiler.vectorization;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
import java.util.Random;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class TestFloat16VectorConvChain {
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"})
|
||||
public static void test(short [] res, short [] src1, short [] src2) {
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = (short)Float.float16ToFloat(Float.floatToFloat16(Float.float16ToFloat(src1[i]) + Float.float16ToFloat(src2[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@Run(test = {"test"})
|
||||
@Warmup(1000)
|
||||
public static void micro() {
|
||||
short [] res = new short[1024];
|
||||
short [] src1 = new short[1024];
|
||||
short [] src2 = new short[1024];
|
||||
Arrays.fill(src1, (short)Float.floatToFloat16(1.0f));
|
||||
Arrays.fill(src2, (short)Float.floatToFloat16(2.0f));
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
test(res, src1, src2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String [] args) {
|
||||
TestFramework.run(TestFloat16VectorConvChain.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user