From fbc1e6661e26c30a9cf7bc57afd70fde1c642bcb Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Tue, 9 Apr 2024 01:37:38 +0000 Subject: [PATCH] 8328181: C2: assert(MaxVectorSize >= 32) failed: vector length should be >= 32 Reviewed-by: kvn, vlivanov --- src/hotspot/cpu/x86/macroAssembler_x86.cpp | 2 +- src/hotspot/cpu/x86/x86.ad | 1 - src/hotspot/cpu/x86/x86_32.ad | 15 +++++++-------- src/hotspot/cpu/x86/x86_64.ad | 13 ++++++------- test/hotspot/jtreg/compiler/c2/ClearArray.java | 2 ++ 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 4ed59ef9908..eb70c807e52 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -5779,7 +5779,7 @@ void MacroAssembler::xmm_clear_mem(Register base, Register cnt, Register rtmp, X // Clearing constant sized memory using YMM/ZMM registers. void MacroAssembler::clear_mem(Register base, int cnt, Register rtmp, XMMRegister xtmp, KRegister mask) { - assert(UseAVX > 2 && VM_Version::supports_avx512vlbw(), ""); + assert(UseAVX > 2 && VM_Version::supports_avx512vl(), ""); bool use64byteVector = (MaxVectorSize > 32) && (VM_Version::avx3_threshold() == 0); int vector64_count = (cnt & (~0x7)) >> 3; diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 0c8fddcdc38..54306d02ea0 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -1750,7 +1750,6 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; - case Op_ClearArray: case Op_VectorMaskGen: case Op_VectorCmpMasked: if (!is_LP64 || !VM_Version::supports_avx512bw()) { diff --git a/src/hotspot/cpu/x86/x86_32.ad b/src/hotspot/cpu/x86/x86_32.ad index 1c9f6fc4134..36ec4d283ed 100644 --- a/src/hotspot/cpu/x86/x86_32.ad +++ b/src/hotspot/cpu/x86/x86_32.ad @@ -11470,8 +11470,8 @@ instruct expandBitsL_reg(eADXRegL dst, eBCXRegL src, eBDPRegL mask, eSIRegI rtmp %} // ======================================================================= -// fast clearing of an array -// Small ClearArray non-AVX512. +// Fast clearing of an array +// Small non-constant length ClearArray for non-AVX512 targets. instruct rep_stos(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{ predicate(!((ClearArrayNode*)n)->is_large() && (UseAVX <= 2)); match(Set dummy (ClearArray cnt base)); @@ -11531,7 +11531,7 @@ instruct rep_stos(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Universe du ins_pipe( pipe_slow ); %} -// Small ClearArray AVX512 non-constant length. +// Small non-constant length ClearArray for AVX512 targets. instruct rep_stos_evex(eCXRegI cnt, eDIRegP base, legRegD tmp, kReg ktmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{ predicate(!((ClearArrayNode*)n)->is_large() && (UseAVX > 2)); match(Set dummy (ClearArray cnt base)); @@ -11592,7 +11592,7 @@ instruct rep_stos_evex(eCXRegI cnt, eDIRegP base, legRegD tmp, kReg ktmp, eAXReg ins_pipe( pipe_slow ); %} -// Large ClearArray non-AVX512. +// Large non-constant length ClearArray for non-AVX512 targets. instruct rep_stos_large(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{ predicate((UseAVX <= 2) && ((ClearArrayNode*)n)->is_large()); match(Set dummy (ClearArray cnt base)); @@ -11642,7 +11642,7 @@ instruct rep_stos_large(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Unive ins_pipe( pipe_slow ); %} -// Large ClearArray AVX512. +// Large non-constant length ClearArray for AVX512 targets. instruct rep_stos_large_evex(eCXRegI cnt, eDIRegP base, legRegD tmp, kReg ktmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{ predicate((UseAVX > 2) && ((ClearArrayNode*)n)->is_large()); match(Set dummy (ClearArray cnt base)); @@ -11692,11 +11692,10 @@ instruct rep_stos_large_evex(eCXRegI cnt, eDIRegP base, legRegD tmp, kReg ktmp, ins_pipe( pipe_slow ); %} -// Small ClearArray AVX512 constant length. +// Small constant length ClearArray for AVX512 targets. instruct rep_stos_im(immI cnt, kReg ktmp, eRegP base, regD tmp, rRegI zero, Universe dummy, eFlagsReg cr) %{ - predicate(!((ClearArrayNode*)n)->is_large() && - ((UseAVX > 2) && VM_Version::supports_avx512vlbw())); + predicate(!((ClearArrayNode*)n)->is_large() && (MaxVectorSize >= 32) && VM_Version::supports_avx512vl()); match(Set dummy (ClearArray cnt base)); ins_cost(100); effect(TEMP tmp, TEMP zero, TEMP ktmp, KILL cr); diff --git a/src/hotspot/cpu/x86/x86_64.ad b/src/hotspot/cpu/x86/x86_64.ad index 8263725f34b..e49deb8f673 100644 --- a/src/hotspot/cpu/x86/x86_64.ad +++ b/src/hotspot/cpu/x86/x86_64.ad @@ -10410,7 +10410,7 @@ instruct MoveL2D_reg_reg(regD dst, rRegL src) %{ %} // Fast clearing of an array -// Small ClearArray non-AVX512. +// Small non-constant lenght ClearArray for non-AVX512 targets. instruct rep_stos(rcx_RegL cnt, rdi_RegP base, regD tmp, rax_RegI zero, Universe dummy, rFlagsReg cr) %{ @@ -10470,7 +10470,7 @@ instruct rep_stos(rcx_RegL cnt, rdi_RegP base, regD tmp, rax_RegI zero, ins_pipe(pipe_slow); %} -// Small ClearArray AVX512 non-constant length. +// Small non-constant length ClearArray for AVX512 targets. instruct rep_stos_evex(rcx_RegL cnt, rdi_RegP base, legRegD tmp, kReg ktmp, rax_RegI zero, Universe dummy, rFlagsReg cr) %{ @@ -10531,7 +10531,7 @@ instruct rep_stos_evex(rcx_RegL cnt, rdi_RegP base, legRegD tmp, kReg ktmp, rax_ ins_pipe(pipe_slow); %} -// Large ClearArray non-AVX512. +// Large non-constant length ClearArray for non-AVX512 targets. instruct rep_stos_large(rcx_RegL cnt, rdi_RegP base, regD tmp, rax_RegI zero, Universe dummy, rFlagsReg cr) %{ @@ -10582,7 +10582,7 @@ instruct rep_stos_large(rcx_RegL cnt, rdi_RegP base, regD tmp, rax_RegI zero, ins_pipe(pipe_slow); %} -// Large ClearArray AVX512. +// Large non-constant length ClearArray for AVX512 targets. instruct rep_stos_large_evex(rcx_RegL cnt, rdi_RegP base, legRegD tmp, kReg ktmp, rax_RegI zero, Universe dummy, rFlagsReg cr) %{ @@ -10633,11 +10633,10 @@ instruct rep_stos_large_evex(rcx_RegL cnt, rdi_RegP base, legRegD tmp, kReg ktmp ins_pipe(pipe_slow); %} -// Small ClearArray AVX512 constant length. +// Small constant length ClearArray for AVX512 targets. instruct rep_stos_im(immL cnt, rRegP base, regD tmp, rRegI zero, kReg ktmp, Universe dummy, rFlagsReg cr) %{ - predicate(!((ClearArrayNode*)n)->is_large() && - ((UseAVX > 2) && VM_Version::supports_avx512vlbw())); + predicate(!((ClearArrayNode*)n)->is_large() && (MaxVectorSize >= 32) && VM_Version::supports_avx512vl()); match(Set dummy (ClearArray cnt base)); ins_cost(100); effect(TEMP tmp, TEMP zero, TEMP ktmp, KILL cr); diff --git a/test/hotspot/jtreg/compiler/c2/ClearArray.java b/test/hotspot/jtreg/compiler/c2/ClearArray.java index 55d717c3119..25ff254c44f 100644 --- a/test/hotspot/jtreg/compiler/c2/ClearArray.java +++ b/test/hotspot/jtreg/compiler/c2/ClearArray.java @@ -31,6 +31,8 @@ * -XX:InitArrayShortSize=32768 -XX:-IdealizeClearArrayNode compiler.c2.ClearArray * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -Xbatch * -XX:InitArrayShortSize=32768 -XX:-IdealizeClearArrayNode -XX:UseAVX=3 compiler.c2.ClearArray + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -Xbatch + * -XX:InitArrayShortSize=32768 -XX:MaxVectorSize=8 -XX:-IdealizeClearArrayNode -XX:UseAVX=3 compiler.c2.ClearArray */ package compiler.c2;