From 4e6cadf4550c58b3ff97dfa0cead4b5b1399324c Mon Sep 17 00:00:00 2001 From: erifan Date: Wed, 5 Nov 2025 02:19:29 +0000 Subject: [PATCH] 8369456: [TESTBUG] Fix the test failure of TestSelectFromTwoVectorOp.java on sve2 platforms Reviewed-by: epeter, bkilambi, xgong, haosun --- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 5 +- src/hotspot/cpu/x86/x86.ad | 2 +- .../vectorapi/TestSelectFromTwoVectorOp.java | 130 +++++++++++++++--- 3 files changed, 115 insertions(+), 22 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 328ef0c53e6..5f71222ed88 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -2722,9 +2722,8 @@ void C2_MacroAssembler::select_from_two_vectors(FloatRegister dst, FloatRegister assert_different_registers(dst, src1, src2, index, tmp); // The cases that can reach this method are - - // - UseSVE = 0, vector_length_in_bytes = 8 or 16 - // - UseSVE = 1, vector_length_in_bytes = 8 or 16 - // - UseSVE = 2, vector_length_in_bytes >= 8 + // - UseSVE = 0/1, vector_length_in_bytes = 8 or 16, excluding double and long types + // - UseSVE = 2, vector_length_in_bytes >= 8, for all types // // SVE/SVE2 tbl instructions are generated when UseSVE = 1 with vector_length_in_bytes = 8 // and UseSVE = 2 with vector_length_in_bytes >= 8 diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 2f19e76baf2..064c52e658b 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -3467,7 +3467,7 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { if (size_in_bits < 128) { return false; } - if ((size_in_bits < 512 && !VM_Version::supports_avx512vl())) { + if (size_in_bits < 512 && !VM_Version::supports_avx512vl()) { return false; } if (bt == T_SHORT && !VM_Version::supports_avx512bw()) { diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestSelectFromTwoVectorOp.java b/test/hotspot/jtreg/compiler/vectorapi/TestSelectFromTwoVectorOp.java index 3746578266c..1320b888ee6 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestSelectFromTwoVectorOp.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestSelectFromTwoVectorOp.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2025, Arm Limited. All rights reserved. + * Copyright (c) 2025, NVIDIA CORPORATION & 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 @@ -185,8 +186,14 @@ public class TestSelectFromTwoVectorOp { @Test @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"}, - applyIfCPUFeature = {"asimd", "true"}, + applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"}, applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) @@ -200,7 +207,10 @@ public class TestSelectFromTwoVectorOp { applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, ">0"}, applyIfCPUFeature = {"sve2", "true"}, - applyIf = {"MaxVectorSize", ">=32"}) + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, ">0"}, applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) @@ -214,7 +224,10 @@ public class TestSelectFromTwoVectorOp { applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, ">0"}, applyIfCPUFeature = {"sve2", "true"}, - applyIf = {"MaxVectorSize", ">=64"}) + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, ">0"}, applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) @@ -248,7 +261,10 @@ public class TestSelectFromTwoVectorOp { applyIf = {"MaxVectorSize", ">=16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, ">0"}, applyIfCPUFeature = {"sve2", "true"}, - applyIf = {"MaxVectorSize", ">=16"}) + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, ">0"}, applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) @@ -262,7 +278,10 @@ public class TestSelectFromTwoVectorOp { applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, ">0"}, applyIfCPUFeature = {"sve2", "true"}, - applyIf = {"MaxVectorSize", ">=32"}) + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, ">0"}, applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) @@ -276,7 +295,10 @@ public class TestSelectFromTwoVectorOp { applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, ">0"}, applyIfCPUFeature = {"sve2", "true"}, - applyIf = {"MaxVectorSize", ">=64"}) + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, ">0"}, applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) @@ -309,7 +331,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) public static void selectFromTwoVector_Int128() { IntSelectFromTwoVectorKernel(IntVector.SPECIES_128, ia, ib, iindex[1]); @@ -320,7 +348,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) public static void selectFromTwoVector_Int256() { IntSelectFromTwoVectorKernel(IntVector.SPECIES_256, ia, ib, iindex[2]); @@ -331,7 +365,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, ">0"}, + applyIfCPUFeature = {"avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) public static void selectFromTwoVector_Int512() { IntSelectFromTwoVectorKernel(IntVector.SPECIES_512, ia, ib, iindex[3]); @@ -362,7 +402,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) public static void selectFromTwoVector_Float128() { FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_128, fa, fb, findex[1]); @@ -373,7 +419,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) public static void selectFromTwoVector_Float256() { FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_256, fa, fb, findex[2]); @@ -384,7 +436,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, ">0"}, + applyIfCPUFeature = {"avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) public static void selectFromTwoVector_Float512() { FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_512, fa, fb, findex[3]); @@ -407,7 +465,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) public static void selectFromTwoVector_Double128() { DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_128, da, db, dindex[0]); @@ -418,7 +482,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) public static void selectFromTwoVector_Double256() { DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_256, da, db, dindex[1]); @@ -429,7 +499,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, ">0"}, + applyIfCPUFeature = {"avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) public static void selectFromTwoVector_Double512() { DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_512, da, db, dindex[2]); @@ -452,7 +528,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=16"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">16"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=16"}) public static void selectFromTwoVector_Long128() { LongSelectFromTwoVectorKernel(LongVector.SPECIES_128, la, lb, lindex[0]); @@ -463,7 +545,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=32"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">32"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, ">0"}, + applyIfCPUFeature = {"avx512vl", "true"}, applyIf = {"MaxVectorSize", ">=32"}) public static void selectFromTwoVector_Long256() { LongSelectFromTwoVectorKernel(LongVector.SPECIES_256, la, lb, lindex[1]); @@ -474,7 +562,13 @@ public class TestSelectFromTwoVectorOp { applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"}, applyIf = {"MaxVectorSize", ">=64"}) @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, ">0"}, - applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", "64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, "0"}, + applyIfCPUFeature = {"sve2", "true"}, + applyIf = {"MaxVectorSize", ">64"}) + @IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, ">0"}, + applyIfCPUFeature = {"avx512f", "true"}, applyIf = {"MaxVectorSize", ">=64"}) public static void selectFromTwoVector_Long512() { LongSelectFromTwoVectorKernel(LongVector.SPECIES_512, la, lb, lindex[2]);