[libc-commits] [libc] b3b5413 - [libc][NFC] Separate avx/no-avx x86 memcpy implementations
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Wed Jun 28 06:57:06 PDT 2023
Author: Guillaume Chatelet
Date: 2023-06-28T13:56:56Z
New Revision: b3b54131d0a025c74082b7cb843d83fbd8814865
URL: https://github.com/llvm/llvm-project/commit/b3b54131d0a025c74082b7cb843d83fbd8814865
DIFF: https://github.com/llvm/llvm-project/commit/b3b54131d0a025c74082b7cb843d83fbd8814865.diff
LOG: [libc][NFC] Separate avx/no-avx x86 memcpy implementations
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D153958
Added:
Modified:
libc/src/string/memory_utils/x86_64/memcpy_implementations.h
Removed:
################################################################################
diff --git a/libc/src/string/memory_utils/x86_64/memcpy_implementations.h b/libc/src/string/memory_utils/x86_64/memcpy_implementations.h
index 3844e06e01ab2..85cd881690464 100644
--- a/libc/src/string/memory_utils/x86_64/memcpy_implementations.h
+++ b/libc/src/string/memory_utils/x86_64/memcpy_implementations.h
@@ -19,7 +19,7 @@
namespace __llvm_libc {
[[maybe_unused]] LIBC_INLINE void
-inline_memcpy_x86(Ptr __restrict dst, CPtr __restrict src, size_t count) {
+inline_memcpy_x86_avx(Ptr __restrict dst, CPtr __restrict src, size_t count) {
if (count == 0)
return;
if (count == 1)
@@ -40,12 +40,47 @@ inline_memcpy_x86(Ptr __restrict dst, CPtr __restrict src, size_t count) {
return builtin::Memcpy<32>::head_tail(dst, src, count);
if (count < 128)
return builtin::Memcpy<64>::head_tail(dst, src, count);
- if (x86::kAvx && count < 256)
+ if (count < 256)
return builtin::Memcpy<128>::head_tail(dst, src, count);
builtin::Memcpy<32>::block(dst, src);
align_to_next_boundary<32, Arg::Dst>(dst, src, count);
- static constexpr size_t kBlockSize = x86::kAvx ? 64 : 32;
- return builtin::Memcpy<kBlockSize>::loop_and_tail(dst, src, count);
+ return builtin::Memcpy<64>::loop_and_tail(dst, src, count);
+}
+
+[[maybe_unused]] LIBC_INLINE void inline_memcpy_x86_no_avx(Ptr __restrict dst,
+ CPtr __restrict src,
+ size_t count) {
+ if (count == 0)
+ return;
+ if (count == 1)
+ return builtin::Memcpy<1>::block(dst, src);
+ if (count == 2)
+ return builtin::Memcpy<2>::block(dst, src);
+ if (count == 3)
+ return builtin::Memcpy<3>::block(dst, src);
+ if (count == 4)
+ return builtin::Memcpy<4>::block(dst, src);
+ if (count < 8)
+ return builtin::Memcpy<4>::head_tail(dst, src, count);
+ if (count < 16)
+ return builtin::Memcpy<8>::head_tail(dst, src, count);
+ if (count < 32)
+ return builtin::Memcpy<16>::head_tail(dst, src, count);
+ if (count < 64)
+ return builtin::Memcpy<32>::head_tail(dst, src, count);
+ if (count < 128)
+ return builtin::Memcpy<64>::head_tail(dst, src, count);
+ builtin::Memcpy<32>::block(dst, src);
+ align_to_next_boundary<32, Arg::Dst>(dst, src, count);
+ return builtin::Memcpy<32>::loop_and_tail(dst, src, count);
+}
+
+[[maybe_unused]] LIBC_INLINE void
+inline_memcpy_x86(Ptr __restrict dst, CPtr __restrict src, size_t count) {
+ if constexpr (x86::kAvx)
+ return inline_memcpy_x86_avx(dst, src, count);
+ else
+ return inline_memcpy_x86_no_avx(dst, src, count);
}
[[maybe_unused]] LIBC_INLINE void
More information about the libc-commits
mailing list