8343419: Assertion failure in long vector unsigned min/max with -XX:+UseKNLSetting

Reviewed-by: sviswanathan
This commit is contained in:
Jatin Bhateja 2024-11-02 01:07:41 +00:00
parent c82ad845e1
commit 3c7082a633
2 changed files with 31 additions and 17 deletions

View File

@ -963,22 +963,33 @@ void C2_MacroAssembler::vpuminmax(int opcode, BasicType elem_bt, XMMRegister dst
}
void C2_MacroAssembler::vpuminmaxq(int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2, XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc) {
// T1 = -1
vpcmpeqq(xtmp1, xtmp1, xtmp1, vlen_enc);
// T1 = -1 << 63
vpsllq(xtmp1, xtmp1, 63, vlen_enc);
// Convert SRC2 to signed value i.e. T2 = T1 + SRC2
vpaddq(xtmp2, xtmp1, src2, vlen_enc);
// Convert SRC1 to signed value i.e. T1 = T1 + SRC1
vpaddq(xtmp1, xtmp1, src1, vlen_enc);
// Mask = T2 > T1
vpcmpgtq(xtmp1, xtmp2, xtmp1, vlen_enc);
if (opcode == Op_UMaxV) {
// Res = Mask ? Src2 : Src1
vpblendvb(dst, src1, src2, xtmp1, vlen_enc);
// For optimality, leverage a full vector width of 512 bits
// for operations over smaller vector sizes on AVX512 targets.
if (VM_Version::supports_evex() && !VM_Version::supports_avx512vl()) {
if (opcode == Op_UMaxV) {
evpmaxuq(dst, k0, src1, src2, false, Assembler::AVX_512bit);
} else {
assert(opcode == Op_UMinV, "required");
evpminuq(dst, k0, src1, src2, false, Assembler::AVX_512bit);
}
} else {
// Res = Mask ? Src1 : Src2
vpblendvb(dst, src2, src1, xtmp1, vlen_enc);
// T1 = -1
vpcmpeqq(xtmp1, xtmp1, xtmp1, vlen_enc);
// T1 = -1 << 63
vpsllq(xtmp1, xtmp1, 63, vlen_enc);
// Convert SRC2 to signed value i.e. T2 = T1 + SRC2
vpaddq(xtmp2, xtmp1, src2, vlen_enc);
// Convert SRC1 to signed value i.e. T1 = T1 + SRC1
vpaddq(xtmp1, xtmp1, src1, vlen_enc);
// Mask = T2 > T1
vpcmpgtq(xtmp1, xtmp2, xtmp1, vlen_enc);
if (opcode == Op_UMaxV) {
// Res = Mask ? Src2 : Src1
vpblendvb(dst, src1, src2, xtmp1, vlen_enc);
} else {
// Res = Mask ? Src1 : Src2
vpblendvb(dst, src2, src1, xtmp1, vlen_enc);
}
}
}

View File

@ -2138,10 +2138,13 @@ bool Matcher::match_rule_supported_vector_masked(int opcode, int vlen, BasicType
case Op_StoreVectorScatterMasked:
return true;
case Op_MaxV:
case Op_MinV:
case Op_UMinV:
case Op_UMaxV:
if (size_in_bits < 512 && !VM_Version::supports_avx512vl()) {
return false;
} // fallthrough
case Op_MaxV:
case Op_MinV:
if (is_subword_type(bt) && !VM_Version::supports_avx512bw()) {
return false; // Implementation limitation
}