diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 022ee391f47..99ba48738ff 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1888,17 +1888,13 @@ bool Matcher::match_rule_supported(int opcode) { } break; + case Op_CompressBits: // fall through + guarantee(UseRVV == (MaxVectorSize >= 16), "UseRVV and MaxVectorSize not matched"); case Op_StrCompressedCopy: // fall through case Op_StrInflatedCopy: // fall through - case Op_CountPositives: - return UseRVV; - - case Op_CompressBits: - guarantee(UseRVV == (MaxVectorSize >= 16), "UseRVV and MaxVectorSize not matched"); - return UseRVV; - + case Op_CountPositives: // fall through case Op_EncodeISOArray: - return UseRVV && SpecialEncodeISOArray; + return UseRVV; case Op_PopCountI: case Op_PopCountL: diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index b7753ed5223..c450b3754df 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -199,16 +199,6 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSignumIntrinsic, true); } - if (UseRVV) { - if (!ext_V.enabled()) { - warning("RVV is not supported on this CPU"); - FLAG_SET_DEFAULT(UseRVV, false); - } else { - // read vector length from vector CSR vlenb - _initial_vector_length = cpu_vector_length(); - } - } - if (UseRVC && !ext_C.enabled()) { warning("RVC is not supported on this CPU"); FLAG_SET_DEFAULT(UseRVC, false); @@ -261,6 +251,25 @@ void VM_Version::initialize() { warning("Block zeroing is not available"); FLAG_SET_DEFAULT(UseBlockZeroing, false); } + + if (UseRVV) { + if (!ext_V.enabled()) { + warning("RVV is not supported on this CPU"); + FLAG_SET_DEFAULT(UseRVV, false); + } else { + // read vector length from vector CSR vlenb + _initial_vector_length = cpu_vector_length(); + } + } + +#ifdef COMPILER2 + c2_initialize(); +#endif // COMPILER2 + + // NOTE: Make sure codes dependent on UseRVV are put after c2_initialize(), + // as there are extra checks inside it which could disable UseRVV + // in some situations. + if (UseRVV) { if (FLAG_IS_DEFAULT(UseChaCha20Intrinsics)) { FLAG_SET_DEFAULT(UseChaCha20Intrinsics, true); @@ -271,10 +280,6 @@ void VM_Version::initialize() { } FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false); } - -#ifdef COMPILER2 - c2_initialize(); -#endif // COMPILER2 } #ifdef COMPILER2 @@ -288,18 +293,9 @@ void VM_Version::c2_initialize() { } if (!UseRVV) { - FLAG_SET_DEFAULT(SpecialEncodeISOArray, false); - } - - if (!UseRVV && MaxVectorSize) { FLAG_SET_DEFAULT(MaxVectorSize, 0); - } - - if (!UseRVV) { FLAG_SET_DEFAULT(UseRVVForBigIntegerShiftIntrinsics, false); - } - - if (UseRVV) { + } else { if (FLAG_IS_DEFAULT(MaxVectorSize)) { MaxVectorSize = _initial_vector_length; } else if (!is_power_of_2(MaxVectorSize)) {