From 24ffb98f9dbd489b05e1b5b36f3c0cd744dc798b Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Fri, 23 Jul 2021 12:19:55 +0000 Subject: [PATCH] [libc] optimize bzero/memset for x86 This is simpy using the x86 optimized elements when targetting x86 cpus. Differential Revision: https://reviews.llvm.org/D106551 --- libc/src/string/memory_utils/memset_utils.h | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libc/src/string/memory_utils/memset_utils.h b/libc/src/string/memory_utils/memset_utils.h index 4826670..be1048a 100644 --- a/libc/src/string/memory_utils/memset_utils.h +++ b/libc/src/string/memory_utils/memset_utils.h @@ -49,28 +49,33 @@ namespace __llvm_libc { // superior for sizes that mattered. inline static void GeneralPurposeMemset(char *dst, unsigned char value, size_t count) { +#if defined(__i386__) || defined(__x86_64__) + using namespace ::__llvm_libc::x86; +#else + using namespace ::__llvm_libc::scalar; +#endif + if (count == 0) return; if (count == 1) - return SplatSet(dst, value); + return SplatSet<_1>(dst, value); if (count == 2) - return SplatSet(dst, value); + return SplatSet<_2>(dst, value); if (count == 3) - return SplatSet(dst, value); + return SplatSet<_3>(dst, value); if (count == 4) - return SplatSet(dst, value); + return SplatSet<_4>(dst, value); if (count <= 8) - return SplatSet>(dst, value, count); + return SplatSet>(dst, value, count); if (count <= 16) - return SplatSet>(dst, value, count); + return SplatSet>(dst, value, count); if (count <= 32) - return SplatSet>(dst, value, count); + return SplatSet>(dst, value, count); if (count <= 64) - return SplatSet>(dst, value, count); + return SplatSet>(dst, value, count); if (count <= 128) - return SplatSet>(dst, value, count); - return SplatSet::Then>>( - dst, value, count); + return SplatSet>(dst, value, count); + return SplatSet::Then>>(dst, value, count); } } // namespace __llvm_libc -- 2.7.4