Enable AES and SHA3 optimisations on Apple Silicon M4-based macOS systems

AES gets a performance enhancement of 7-33%.

Tested on an M4 Pro, but the CPU cores are the same on M4 and M4 Max.

Change-Id: I634c03f1d2b50fa5f8ca97dd65975e49d970c72b

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/25940)
This commit is contained in:
Tom Cosgrove 2024-11-12 08:27:27 +00:00 committed by Tomas Mraz
parent 635bf4946a
commit ea5817854c

View File

@ -300,7 +300,8 @@ void OPENSSL_cpuid_setup(void)
if ((sysctlbyname("machdep.cpu.brand_string", uarch, &len, NULL, 0) == 0) &&
((strncmp(uarch, "Apple M1", 8) == 0) ||
(strncmp(uarch, "Apple M2", 8) == 0) ||
(strncmp(uarch, "Apple M3", 8) == 0))) {
(strncmp(uarch, "Apple M3", 8) == 0) ||
(strncmp(uarch, "Apple M4", 8) == 0))) {
OPENSSL_armcap_P |= ARMV8_UNROLL8_EOR3;
OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
}