2626 * @bug 8294588
2727 * @summary Auto-vectorize Float.floatToFloat16, Float.float16ToFloat APIs
2828 * @requires vm.compiler2.enabled
29- * @requires (os.simpleArch == "x64" & (vm.cpu.features ~= ".*avx512f.*" | vm.cpu.features ~= ".*f16c.*")) |
30- * os.arch == "aarch64" |
31- * (os.arch == "riscv64" & vm.cpu.features ~= ".*zvfh.*")
3229 * @library /test/lib /
3330 * @run driver compiler.vectorization.TestFloatConversionsVector
3431 */
@@ -53,7 +50,9 @@ public static void main(String args[]) {
5350 }
5451
5552 @ Test
56- @ IR (counts = {IRNode .VECTOR_CAST_F2HF , IRNode .VECTOR_SIZE + "min(max_float, max_short)" , "> 0" })
53+ @ IR (counts = {IRNode .VECTOR_CAST_F2HF , IRNode .VECTOR_SIZE + "min(max_float, max_short)" , "> 0" },
54+ applyIfPlatformOr = {"x64" , "true" , "aarch64" , "true" , "riscv64" , "true" },
55+ applyIfCPUFeatureOr = {"f16c" , "true" , "avx512f" , "true" , "zvfh" , "true" , "asimd" , "true" , "sve" , "true" })
5756 public void test_float_float16 (short [] sout , float [] finp ) {
5857 for (int i = 0 ; i < finp .length ; i ++) {
5958 sout [i ] = Float .floatToFloat16 (finp [i ]);
@@ -67,7 +66,16 @@ public void test_float_float16_strided(short[] sout, float[] finp) {
6766 }
6867 }
6968
70- @ Run (test = {"test_float_float16" , "test_float_float16_strided" }, mode = RunMode .STANDALONE )
69+ @ Test
70+ public void test_float_float16_short_vector (short [] sout , float [] finp ) {
71+ for (int i = 0 ; i < finp .length ; i += 4 ) {
72+ sout [i +0 ] = Float .floatToFloat16 (finp [i +0 ]);
73+ sout [i +1 ] = Float .floatToFloat16 (finp [i +1 ]);
74+ }
75+ }
76+
77+ @ Run (test = {"test_float_float16" , "test_float_float16_strided" ,
78+ "test_float_float16_short_vector" }, mode = RunMode .STANDALONE )
7179 public void kernel_test_float_float16 () {
7280 finp = new float [ARRLEN ];
7381 sout = new short [ARRLEN ];
@@ -93,10 +101,21 @@ public void kernel_test_float_float16() {
93101 for (int i = 0 ; i < ARRLEN /2 ; i ++) {
94102 Asserts .assertEquals (Float .floatToFloat16 (finp [i *2 ]), sout [i *2 ]);
95103 }
104+
105+ for (int i = 0 ; i < ITERS ; i ++) {
106+ test_float_float16_short_vector (sout , finp );
107+ }
108+
109+ // Verifying the result
110+ for (int i = 0 ; i < ARRLEN ; i ++) {
111+ Asserts .assertEquals (Float .floatToFloat16 (finp [i ]), sout [i ]);
112+ }
96113 }
97114
98115 @ Test
99- @ IR (counts = {IRNode .VECTOR_CAST_HF2F , IRNode .VECTOR_SIZE + "min(max_float, max_short)" , "> 0" })
116+ @ IR (counts = {IRNode .VECTOR_CAST_HF2F , IRNode .VECTOR_SIZE + "min(max_float, max_short)" , "> 0" },
117+ applyIfPlatformOr = {"x64" , "true" , "aarch64" , "true" , "riscv64" , "true" },
118+ applyIfCPUFeatureOr = {"f16c" , "true" , "avx512f" , "true" , "zvfh" , "true" , "asimd" , "true" , "sve" , "true" })
100119 public void test_float16_float (float [] fout , short [] sinp ) {
101120 for (int i = 0 ; i < sinp .length ; i ++) {
102121 fout [i ] = Float .float16ToFloat (sinp [i ]);
0 commit comments