Skip to content

Commit

Permalink
8319781: RISC-V: Refactor UseRVV related checks
Browse files Browse the repository at this point in the history
Reviewed-by: rehn, fyang
  • Loading branch information
Hamlin Li committed Nov 15, 2023
1 parent bad6999 commit fac6b51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
12 changes: 4 additions & 8 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 20 additions & 24 deletions src/hotspot/cpu/riscv/vm_version_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -271,10 +280,6 @@ void VM_Version::initialize() {
}
FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
}

#ifdef COMPILER2
c2_initialize();
#endif // COMPILER2
}

#ifdef COMPILER2
Expand All @@ -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)) {
Expand Down

1 comment on commit fac6b51

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.