From f22a2108c4eabe7313c698ed04024b73850d405e Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Mon, 22 May 2023 14:49:31 -0700 Subject: Improve performance of syscalls/memcpy --- benchmarks/common/syscalls.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'benchmarks/common') diff --git a/benchmarks/common/syscalls.c b/benchmarks/common/syscalls.c index 39547b3..7a7b7fd 100644 --- a/benchmarks/common/syscalls.c +++ b/benchmarks/common/syscalls.c @@ -381,7 +381,21 @@ void* memcpy(void* dest, const void* src, size_t len) if ((((uintptr_t)dest | (uintptr_t)src | len) & (sizeof(uintptr_t)-1)) == 0) { const uintptr_t* s = src; uintptr_t *d = dest; - while (d < (uintptr_t*)(dest + len)) + uintptr_t *end = dest + len; + while (d + 8 < end) { + uintptr_t reg[8] = {s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]}; + d[0] = reg[0]; + d[1] = reg[1]; + d[2] = reg[2]; + d[3] = reg[3]; + d[4] = reg[4]; + d[5] = reg[5]; + d[6] = reg[6]; + d[7] = reg[7]; + d += 8; + s += 8; + } + while (d < end) *d++ = *s++; } else { const char* s = src; -- cgit v1.1