From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693635075; bh=lCMYa3kM0Ko+YgeAa8nfhXpd5/xQ5+E68evNTg4CTvk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Q2JVtYnWywreIhcjy9KjjedFJ3CSVL3+lBEOwhkOsKVPpGAouU/lFTIZH6Vh0+tV+ 3jXHcQLOsYm5W5sTLTxSoK698Ta50AGVvutU8KVMOwfI/8e1RX0iCpBWfS6bx628uc jCRko1UBRWGj5hrZes9x88jbEc44QqjTVDmITtAdLuIT81Ualyga5p+9rebp5eM+hg tnNLoWcf6MVhP1oTZ+S9/sN7uWJWBMzqGCviUjilznyi1tqhnVsy/eDBxGblM5mV4m sBacRJ/aDnDznl+T81fckHx9zD+rWTFXcXj9WxuGtUpeAXCZoH46FMTpKqd/UEZakz EH3FwW1vaTmyg== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 022BA24B39E; Sat, 2 Sep 2023 13:11:11 +0700 (WIB) Date: Sat, 2 Sep 2023 13:11:06 +0700 From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Willy Tarreau , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , David Laight , Nicholas Rosenberg , Michael William Jonathan , GNU/Weeb Mailing List , Linux Kernel Mailing List Subject: Re: [RFC PATCH v2 1/4] tools/nolibc: x86-64: Use `rep movsb` for `memcpy()` and `memmove()` Message-ID: References: <20230902055045.2138405-1-ammarfaizi2@gnuweeb.org> <20230902055045.2138405-2-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: 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