lkml.org 
[lkml]   [2023]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 1/4] tools/nolibc: x86-64: Use `rep movsb` for `memcpy()` and `memmove()`
On Sat, Sep 02, 2023 at 01:07:50PM +0700, Alviro Iskandar Setiawan wrote:
> Btw, sir, this can be simplified more by merging the forward copy
> path, only using two "rep movsb" for both memmove() and memcpy()
> should be enough?
> ```
> __asm__ (
> ".section .text.nolibc_memmove_memcpy\n"
> ".weak memmove\n"
> ".weak memcpy\n"
> "memmove:\n"
> "movq %rdx, %rcx\n"
> "movq %rdi, %rdx\n"
> "movq %rdi, %rax\n"
> "subq %rsi, %rdx\n"
> "cmpq %rcx, %rdx\n"
> "jnb __nolibc_forward_copy\n"
> "leaq -1(%rdi, %rcx, 1), %rdi\n"
> "leaq -1(%rsi, %rcx, 1), %rsi\n"
> "std\n"
> "rep movsb\n"
> "cld\n"
> "retq\n"
>
> "memcpy:\n"
> "movq %rdi, %rax\n"
> "movq %rdx, %rcx\n"
> "__nolibc_forward_copy:\n"
> "rep movsb\n"
> "retq\n"
> );
> ```

Looks good. I'll apply that change.

--
Ammar Faizi

\
 
 \ /
  Last update: 2023-09-02 08:12    [W:0.046 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site