From 076c49771fd06ddf096d49ce6bee741eefc392ec Mon Sep 17 00:00:00 2001 From: Yibo Cai Date: Sun, 19 Mar 2023 13:26:23 +0800 Subject: [PATCH] Optimize my_convert for Arm64 my_convert() copies ascii string in 4 bytes on x86, but not Arm. This patch enables the optimized code path on Arm64. --- strings/ctype.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/strings/ctype.cc b/strings/ctype.cc index 0fa739c6..8a3523ee 100644 --- a/strings/ctype.cc +++ b/strings/ctype.cc @@ -919,9 +919,10 @@ size_t my_convert(char *to, size_t to_length, const CHARSET_INFO *to_cs, length = length2 = std::min(to_length, from_length); -#if defined(__i386__) || defined(_WIN32) || defined(__x86_64__) +#if defined(__i386__) || defined(_WIN32) || defined(__x86_64__) || \ + defined(__aarch64__) || defined(_M_ARM64) /* - Special loop for i386, it allows to refer to a + Special loop for i386/arm, it allows to refer to a non-aligned memory block as UINT32, which makes it possible to copy four bytes at once. This gives about 10% performance improvement comparing @@ -931,7 +932,7 @@ size_t my_convert(char *to, size_t to_length, const CHARSET_INFO *to_cs, if (uint4korr(from) & 0x80808080) break; int4store(to, uint4korr(from)); } -#endif /* __i386__ */ +#endif /* __i386__, __aarch64__ */ for (;; *to++ = *from++, length--) { if (!length) { -- 2.25.1