From ea5817854cf67b89c874101f209f06ae016fd333 Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Tue, 12 Nov 2024 08:27:27 +0000 Subject: [PATCH] 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 Reviewed-by: Kurt Roeckx (Merged from https://github.com/openssl/openssl/pull/25940) --- crypto/armcap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/armcap.c b/crypto/armcap.c index 33b9dd4df08c3..7c5a127523acb 100644 --- a/crypto/armcap.c +++ b/crypto/armcap.c @@ -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; }