8369456: [TESTBUG] Fix the test failure of TestSelectFromTwoVectorOp.java on sve2 platforms

Reviewed-by: epeter, bkilambi, xgong, haosun
This commit is contained in:
erifan 2025-11-05 02:19:29 +00:00 committed by Hao Sun
parent 87c2091cd0
commit 4e6cadf455
3 changed files with 115 additions and 22 deletions

View File

@ -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

View File

@ -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()) {

View File

@ -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]);