Enable AES optimisation on Apple Silicon M2-based systems

Gives a performance enhancement of 16-38%, similar to the M1.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20141)
This commit is contained in:
Tom Cosgrove 2023-01-25 19:34:25 +00:00 committed by Pauli
parent a4347a9a57
commit d79bb5316e

View File

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