From 557cc82359fdd0b1617fc8386ea030c6fc52acd6 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 23 Oct 2024 14:33:48 +0530 Subject: [PATCH] Adjust defaults to prevent code-size regression Signed-off-by: Dave Rodgman --- drivers/builtin/src/chacha20.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/builtin/src/chacha20.c b/drivers/builtin/src/chacha20.c index 11bdc7589..85d352736 100644 --- a/drivers/builtin/src/chacha20.c +++ b/drivers/builtin/src/chacha20.c @@ -55,13 +55,24 @@ // Select scalar implementation if Neon not available #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 0 #elif !defined(MBEDTLS_CHACHA20_NEON_MULTIBLOCK) -// By default, select the best performing option that is smaller than the scalar implementation. +// By default, select the best performing option that is not a code-size regression (based on +// measurements from recent gcc and clang). +#if defined(MBEDTLS_ARCH_IS_THUMB) + #if defined(MBEDTLS_COMPILER_IS_GCC) + #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 1 + #else + #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 2 + #endif +#elif defined(MBEDTLS_ARCH_IS_ARM64) + #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 3 +#else #if defined(MBEDTLS_COMPILER_IS_GCC) #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 2 #else #define MBEDTLS_CHACHA20_NEON_MULTIBLOCK 3 #endif #endif +#endif #if MBEDTLS_CHACHA20_NEON_MULTIBLOCK != 0 // Tested on all combinations of Armv7 arm/thumb2; Armv8 arm/thumb2/aarch64; Armv8 aarch64_be on