@@ -375,24 +375,18 @@ void VM_Version::initialize() {
375375 FLAG_SET_DEFAULT (UseSHA256Intrinsics, false );
376376 }
377377
378- if (UseSHA && VM_Version::supports_sha3 () && _cpu == CPU_APPLE && FLAG_IS_DEFAULT (UseSIMDForSHA3Intrinsic)) {
379- // Note: SIMD faster on Apple, worse on Neoverse V1, V2 and N2.
380- FLAG_SET_DEFAULT (UseSIMDForSHA3Intrinsic, true );
381- }
382-
383- // Enable SHA-3 intrinsics (SIMD or GPR). The GPR path does not require SHA instructions.
384- if (FLAG_IS_DEFAULT (UseSHA3Intrinsics)) {
385- FLAG_SET_DEFAULT (UseSHA3Intrinsics, true );
386- }
387-
388- if (!UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) {
389- // Keep flags consistent: if SHA3 intrinsics are off, disable the SHA3 SIMD variant.
390- FLAG_SET_DEFAULT (UseSIMDForSHA3Intrinsic, false );
391- }
392-
393- if (!VM_Version::supports_sha3 () && UseSIMDForSHA3Intrinsic) {
394- warning (" SHA3 instructions are not available on this CPU" );
395- FLAG_SET_DEFAULT (UseSIMDForSHA3Intrinsic, false );
378+ if (UseSHA && VM_Version::supports_sha3 ()) {
379+ // Auto-enable UseSHA3Intrinsics on hardware with performance benefit.
380+ // Note that the evaluation of UseSHA3Intrinsics shows better performance
381+ // on Apple silicon but worse performance on Neoverse V1 and N2.
382+ if (_cpu == CPU_APPLE) { // Apple silicon
383+ if (FLAG_IS_DEFAULT (UseSHA3Intrinsics)) {
384+ FLAG_SET_DEFAULT (UseSHA3Intrinsics, true );
385+ }
386+ }
387+ } else if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) {
388+ warning (" Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU." );
389+ FLAG_SET_DEFAULT (UseSHA3Intrinsics, false );
396390 }
397391
398392 if (UseSHA && VM_Version::supports_sha512 ()) {
0 commit comments