Skip to content

Commit 3d6824e

Browse files
committed
8371432: [BACKOUT] 8359256: AArch64: Use SHA3 GPR intrinsic where it's faster
Reviewed-by: mchevalier, epeter, syan
1 parent 48bbc95 commit 3d6824e

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/hotspot/cpu/aarch64/globals_aarch64.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
9595
"Use simplest and shortest implementation for array equals") \
9696
product(bool, UseSIMDForBigIntegerShiftIntrinsics, true, \
9797
"Use SIMD instructions for left/right shift of BigInteger") \
98-
product(bool, UseSIMDForSHA3Intrinsic, false, \
98+
product(bool, UseSIMDForSHA3Intrinsic, true, \
9999
"Use SIMD SHA3 instructions for SHA3 intrinsic") \
100100
product(bool, AvoidUnalignedAccesses, false, \
101101
"Avoid generating unaligned memory accesses") \

src/hotspot/cpu/aarch64/vm_version_aarch64.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)