8282764: AArch64: compiler/vectorapi/reshape/TestVectorCastNeon.java failed with incorrect result

Reviewed-by: psandoz, ngasson, eliu
This commit is contained in:
Ningsheng Jian 2022-03-30 09:47:20 +00:00
parent b82b009047
commit 51c05e8219
12 changed files with 51 additions and 25 deletions

View File

@ -350,16 +350,23 @@ instruct vcvt4Bto4I(vecX dst, vecD src)
ins_pipe(pipe_class_default);
%}
instruct vcvt2Lto2F(vecD dst, vecX src)
instruct vcvt2Lto2F(vecD dst, vecX src, vRegF tmp)
%{
predicate(n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT);
match(Set dst (VectorCastL2X src));
format %{ "scvtfv T2D, $dst, $src\n\t"
"fcvtn $dst, T2S, $dst, T2D\t# convert 2L to 2F vector"
effect(TEMP_DEF dst, TEMP tmp);
format %{ "umov rscratch1, $src, D, 0\n\t"
"scvtfs $dst, rscratch1\n\t"
"umov rscratch1, $src, D, 1\n\t"
"scvtfs $tmp, rscratch1\n\t"
"ins $dst, S, $tmp, 1, 0\t# convert 2L to 2F vector"
%}
ins_encode %{
__ scvtfv(__ T2D, as_FloatRegister($dst$$reg), as_FloatRegister($src$$reg));
__ fcvtn(as_FloatRegister($dst$$reg), __ T2S, as_FloatRegister($dst$$reg), __ T2D);
__ umov(rscratch1, as_FloatRegister($src$$reg), __ D, 0);
__ scvtfs(as_FloatRegister($dst$$reg), rscratch1);
__ umov(rscratch1, as_FloatRegister($src$$reg), __ D, 1);
__ scvtfs(as_FloatRegister($tmp$$reg), rscratch1);
__ ins(as_FloatRegister($dst$$reg), __ S, as_FloatRegister($tmp$$reg), 1, 0);
%}
ins_pipe(pipe_slow);
%}

View File

@ -178,16 +178,23 @@ VECTOR_CAST_I2I_L(4, I, B, D, X, xtn, 4S, 4H, 8H, 8B)
VECTOR_CAST_I2I_L(4, B, I, X, D, sxtl, 8B, 8H, 4H, 4S)
dnl
instruct vcvt2Lto2F(vecD dst, vecX src)
instruct vcvt2Lto2F(vecD dst, vecX src, vRegF tmp)
%{
predicate(n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT);
match(Set dst (VectorCastL2X src));
format %{ "scvtfv T2D, $dst, $src\n\t"
"fcvtn $dst, T2S, $dst, T2D\t# convert 2L to 2F vector"
effect(TEMP_DEF dst, TEMP tmp);
format %{ "umov rscratch1, $src, D, 0\n\t"
"scvtfs $dst, rscratch1\n\t"
"umov rscratch1, $src, D, 1\n\t"
"scvtfs $tmp, rscratch1\n\t"
"ins $dst, S, $tmp, 1, 0\t# convert 2L to 2F vector"
%}
ins_encode %{
__ scvtfv(__ T2D, as_FloatRegister($dst$$reg), as_FloatRegister($src$$reg));
__ fcvtn(as_FloatRegister($dst$$reg), __ T2S, as_FloatRegister($dst$$reg), __ T2D);
__ umov(rscratch1, as_FloatRegister($src$$reg), __ D, 0);
__ scvtfs(as_FloatRegister($dst$$reg), rscratch1);
__ umov(rscratch1, as_FloatRegister($src$$reg), __ D, 1);
__ scvtfs(as_FloatRegister($tmp$$reg), rscratch1);
__ ins(as_FloatRegister($dst$$reg), __ S, as_FloatRegister($tmp$$reg), 1, 0);
%}
ins_pipe(pipe_slow);
%}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Arm Limited. All rights reserved.
* Copyright (c) 2021, 2022, Arm Limited. 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
@ -114,6 +114,9 @@ public class VectorCastShape128Test {
0,
Long.MAX_VALUE,
Long.MIN_VALUE,
// A special value to make sure correct rounding of
// conversion from long to float. See: JDK-8282764.
0x561a524000000001L,
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on avx1.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on avx2.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on avx512.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8278623
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on avx512bw.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on avx512dq.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on neon.
@ -42,7 +43,7 @@ public class TestVectorCastNeon {
VectorReshapeHelper.runMainHelper(
TestVectorCast.class,
TestCastMethods.NEON_CAST_TESTS.stream(),
"-XX:+UseNeon");
"-XX:UseSVE=0");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -30,6 +30,7 @@ import compiler.vectorapi.reshape.utils.VectorReshapeHelper;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector cast intrinsics work as intended on sve.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -35,6 +35,7 @@ import jdk.incubator.vector.VectorSpecies;
/*
* @test
* @bug 8259610
* @key randomness
* @modules jdk.incubator.vector
* @modules java.base/jdk.internal.misc
* @summary Test that vector reinterpret intrinsics work as intended.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -37,6 +37,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.incubator.vector.*;
import jdk.test.lib.Asserts;
import jdk.test.lib.Utils;
public class VectorReshapeHelper {
public static final int INVOCATIONS = 10_000;
@ -105,7 +106,7 @@ public class VectorReshapeHelper {
public static <T, U> void runCastHelper(VectorOperators.Conversion<T, U> castOp,
VectorSpecies<T> isp, VectorSpecies<U> osp) throws Throwable {
var random = RandomGenerator.getDefault();
var random = Utils.getRandomInstance();
boolean isUnsignedCast = castOp.name().startsWith("ZERO");
String testMethodName = VectorSpeciesPair.makePair(isp, osp, isUnsignedCast).format();
var caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
@ -219,7 +220,7 @@ public class VectorReshapeHelper {
}
public static void runExpandShrinkHelper(VectorSpecies<Byte> isp, VectorSpecies<Byte> osp) throws Throwable {
var random = RandomGenerator.getDefault();
var random = Utils.getRandomInstance();
String testMethodName = VectorSpeciesPair.makePair(isp, osp).format();
var caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
var testMethod = MethodHandles.lookup().findStatic(caller,
@ -249,7 +250,7 @@ public class VectorReshapeHelper {
}
public static void runDoubleExpandShrinkHelper(VectorSpecies<Byte> isp, VectorSpecies<Byte> osp) throws Throwable {
var random = RandomGenerator.getDefault();
var random = Utils.getRandomInstance();
String testMethodName = VectorSpeciesPair.makePair(isp, osp).format();
var caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
var testMethod = MethodHandles.lookup().findStatic(caller,
@ -278,7 +279,7 @@ public class VectorReshapeHelper {
}
public static <T, U> void runRebracketHelper(VectorSpecies<T> isp, VectorSpecies<U> osp) throws Throwable {
var random = RandomGenerator.getDefault();
var random = Utils.getRandomInstance();
String testMethodName = VectorSpeciesPair.makePair(isp, osp).format();
var caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass();
var testMethod = MethodHandles.lookup().findStatic(caller,