[libc-commits] [libc] [libc] memmove optimizations (PR #70043)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Wed Oct 25 03:35:49 PDT 2023
gchatelet wrote:
And how about splitting `inline_memmove` into several functions:
- `bool inline_memmove_small_size()` returning whether the size was handled
- `inline_memmove_follow_up` (or `inline_memmove_larger_sizes`)
We'd have the following code
```
LLVM_LIBC_FUNCTION(void *, memmove, (void *dst, const void *src, size_t count)) {
if (inline_memmove_small_size(dst, src, count))
return dst;
if (is_disjoint(dst, src, count))
inline_memcpy(dst, src, count);
else
inline_memmove_follow_up(dst, src, count);
return dst;
}
```
Each arch would be responsible for providing the implementations side by side so we can visually check they complement each other. For arch where we don't have a fast path `inline_memmove_small_size` would be
```
constexpr bool inline_memmove_small_size(void *dst, const void *src, size_t count) {
return false;
}
```
Inlining would remove the branch altogether.
WDTY?
https://github.com/llvm/llvm-project/pull/70043
More information about the libc-commits
mailing list