diff a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -499,11 +499,11 @@ if (FLAG_IS_DEFAULT(MaxVectorSize)) { MaxVectorSize = _initial_sve_vector_length; } else if (MaxVectorSize < 16) { warning("SVE does not support vector length less than 16 bytes. Disabling SVE."); UseSVE = 0; - } else if (MaxVectorSize % 16 == 0) { + } else if ((MaxVectorSize % 16) == 0 && is_power_of_2(MaxVectorSize)) { int new_vl = prctl(PR_SVE_SET_VL, MaxVectorSize); _initial_sve_vector_length = new_vl; // If MaxVectorSize is larger than system largest supported SVE vector length, above prctl() // call will set task vector length to the system largest supported value. So, we also update // MaxVectorSize to that largest supported value. @@ -519,10 +519,28 @@ } else { vm_exit_during_initialization(err_msg("Unsupported MaxVectorSize: %d", (int)MaxVectorSize)); } } + if (UseSVE == 0) { // NEON + int min_vector_size = 8; + int max_vector_size = 16; + if (!FLAG_IS_DEFAULT(MaxVectorSize)) { + if (!is_power_of_2(MaxVectorSize)) { + vm_exit_during_initialization(err_msg("Unsupported MaxVectorSize: %d", (int)MaxVectorSize)); + } else if (MaxVectorSize < min_vector_size) { + warning("MaxVectorSize must be at least %i on this platform", min_vector_size); + FLAG_SET_DEFAULT(MaxVectorSize, min_vector_size); + } else if (MaxVectorSize > max_vector_size) { + warning("MaxVectorSize must be at most %i on this platform", max_vector_size); + FLAG_SET_DEFAULT(MaxVectorSize, max_vector_size); + } + } else { + FLAG_SET_DEFAULT(MaxVectorSize, 16); + } + } + if (FLAG_IS_DEFAULT(OptoScheduling)) { OptoScheduling = true; } if (FLAG_IS_DEFAULT(AlignVector)) {