[PATCH 3/6] newlib: mem[p]cpy/memmove improve performance for optimized versions

Alexey Lapshin <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
This change improves performance on memory blocks with sizes in range
[4..15]. Performance measurements made for RISCV machine (memset):

size  4, CPU cycles change: 50 -> 37
size  5, CPU cycles change: 57 -> 40
size  6, CPU cycles change: 64 -> 47
size  7, CPU cycles change: 71 -> 54
size  8, CPU cycles change: 78 -> 44
size  9, CPU cycles change: 85 -> 47
size 10, CPU cycles change: 92 -> 54
size 11, CPU cycles change: 99 -> 61
size 12, CPU cycles change: 106 -> 51
size 13, CPU cycles change: 113 -> 54
size 14, CPU cycles change: 120 -> 61
size 15, CPU cycles change: 127 -> 68
---
 newlib/libc/string/memcpy.c  | 2 +-
 newlib/libc/string/memmove.c | 2 +-
 newlib/libc/string/mempcpy.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/string/memcpy.c b/newlib/libc/string/memcpy.c
index 1bbd4e0bf..e680c444d 100644
--- a/newlib/libc/string/memcpy.c
+++ b/newlib/libc/string/memcpy.c
@@ -57,7 +57,7 @@ memcpy (void *__restrict dst0,
 
   /* If the size is small, or either SRC or DST is unaligned,
      then punt into the byte copy loop.  This should be rare.  */
-  if (!TOO_SMALL_BIG_BLOCK(len0) && !UNALIGNED_X_Y(src, dst))
+  if (!TOO_SMALL_LITTLE_BLOCK(len0) && !UNALIGNED_X_Y(src, dst))
     {
       aligned_dst = (long*)dst;
       aligned_src = (long*)src;
diff --git a/newlib/libc/string/memmove.c b/newlib/libc/string/memmove.c
index a82744c7d..4c5ec6f83 100644
--- a/newlib/libc/string/memmove.c
+++ b/newlib/libc/string/memmove.c
@@ -85,7 +85,7 @@ memmove (void *dst_void,
       /* Use optimizing algorithm for a non-destructive copy to closely 
          match memcpy. If the size is small or either SRC or DST is unaligned,
          then punt into the byte copy loop.  This should be rare.  */
-      if (!TOO_SMALL_BIG_BLOCK(length) && !UNALIGNED_X_Y(src, dst))
+      if (!TOO_SMALL_LITTLE_BLOCK(length) && !UNALIGNED_X_Y(src, dst))
         {
           aligned_dst = (long*)dst;
           aligned_src = (long*)src;
diff --git a/newlib/libc/string/mempcpy.c b/newlib/libc/string/mempcpy.c
index 06e97de85..561892199 100644
--- a/newlib/libc/string/mempcpy.c
+++ b/newlib/libc/string/mempcpy.c
@@ -53,7 +53,7 @@ mempcpy (void *dst0,
 
   /* If the size is small, or either SRC or DST is unaligned,
      then punt into the byte copy loop.  This should be rare.  */
-  if (!TOO_SMALL_BIG_BLOCK(len0) && !UNALIGNED_X_Y(src, dst))
+  if (!TOO_SMALL_LITTLE_BLOCK(len0) && !UNALIGNED_X_Y(src, dst))
     {
       aligned_dst = (long*)dst;
       aligned_src = (long*)src;
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.