[v2] aarch64: Remove duplicated optimized memmove()

Message ID 20231027181833.28871-1-sebastian.huber@embedded-brains.de
State New
Headers
Series [v2] aarch64: Remove duplicated optimized memmove() |

Commit Message

Sebastian Huber Oct. 27, 2023, 6:18 p.m. UTC
  The optimized aarch64/memcpy.S already provides a memmove() implementation.
---

v2: Rename memmove-stub.c in memmove.c to make the build system happy.

 newlib/Makefile.in                            |  42 ++---
 newlib/libc/machine/aarch64/Makefile.inc      |   3 +-
 newlib/libc/machine/aarch64/memmove.S         | 155 ------------------
 .../aarch64/{memmove-stub.c => memmove.c}     |   2 +-
 4 files changed, 13 insertions(+), 189 deletions(-)
 delete mode 100644 newlib/libc/machine/aarch64/memmove.S
 rename newlib/libc/machine/aarch64/{memmove-stub.c => memmove.c} (98%)
  

Comments

Joel Sherrill Oct. 27, 2023, 7 p.m. UTC | #1
Based on a build and nm, memmove and memcpy are coming from the machine
optimized version and memmove.o is empty.

The patch looks like it fixes the problem.  The autotools stuff will need
regeneration after it is pushed. I couldn't do that when I tried.

If someone can push it and regenerate, that would be very much appreciated.

Thanks.

--joel

On Fri, Oct 27, 2023 at 1:18 PM Sebastian Huber <
sebastian.huber@embedded-brains.de> wrote:

> The optimized aarch64/memcpy.S already provides a memmove() implementation.
> ---
>
> v2: Rename memmove-stub.c in memmove.c to make the build system happy.
>
>  newlib/Makefile.in                            |  42 ++---
>  newlib/libc/machine/aarch64/Makefile.inc      |   3 +-
>  newlib/libc/machine/aarch64/memmove.S         | 155 ------------------
>  .../aarch64/{memmove-stub.c => memmove.c}     |   2 +-
>  4 files changed, 13 insertions(+), 189 deletions(-)
>  delete mode 100644 newlib/libc/machine/aarch64/memmove.S
>  rename newlib/libc/machine/aarch64/{memmove-stub.c => memmove.c} (98%)
>
> diff --git a/newlib/Makefile.in b/newlib/Makefile.in
> index 4cb3534cc4..4f0b3bf644 100644
> --- a/newlib/Makefile.in
> +++ b/newlib/Makefile.in
> @@ -594,8 +594,7 @@ check_PROGRAMS =
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memcmp.S \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/memcpy-stub.c \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memcpy.S \
> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/memmove-stub.c \
> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memmove.S \
> +@HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memmove.c \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/memrchr-stub.c \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memrchr.S \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/memset-stub.c \
> @@ -1847,7 +1846,6 @@ am__objects_51 = libc/ssp/libc_a-chk_fail.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memcmp.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memcpy.$(OBJEXT) \
> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memmove.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memrchr-stub.$(OBJEXT) \
>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>  libc/machine/aarch64/libc_a-memrchr.$(OBJEXT) \
> @@ -8022,9 +8020,6 @@ libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT):  \
>  libc/machine/aarch64/libc_a-memcpy.$(OBJEXT):  \
>         libc/machine/aarch64/$(am__dirstamp) \
>         libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
> -libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT):  \
> -       libc/machine/aarch64/$(am__dirstamp) \
> -       libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
>  libc/machine/aarch64/libc_a-memmove.$(OBJEXT):  \
>         libc/machine/aarch64/$(am__dirstamp) \
>         libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
> @@ -12738,7 +12733,6 @@ distclean-compile:
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memcmp.Po@am__quote@
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memcpy-stub.Po@am__quote@
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memcpy.Po@am__quote@
> -@AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po@am__quote@
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memmove.Po@am__quote@
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Po@am__quote@
>  @AMDEP_TRUE@@am__include@ @am__quote@libc
> /machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po@am__quote@
> @@ -16709,20 +16703,6 @@ libc/machine/aarch64/libc_a-memcpy.obj:
> libc/machine/aarch64/memcpy.S
>  @AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
>  @am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
> libc/machine/aarch64/libc_a-memcpy.obj `if test -f
> 'libc/machine/aarch64/memcpy.S'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memcpy.S'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memcpy.S'; fi`
>
> -libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.S
> -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
> -MT libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove.o `test -f
> 'libc/machine/aarch64/memmove.S' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove.S
> -@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@
> $(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S'
> object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
> -@am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
> libc/machine/aarch64/libc_a-memmove.o `test -f
> 'libc/machine/aarch64/memmove.S' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove.S
> -
> -libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.S
> -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
> -MT libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove.obj `if test -f
> 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
> -@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@
> $(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S'
> object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
> -@am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
> libc/machine/aarch64/libc_a-memmove.obj `if test -f
> 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
> -
>  libc/machine/aarch64/libc_a-memrchr.o: libc/machine/aarch64/memrchr.S
>  @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
> -MT libc/machine/aarch64/libc_a-memrchr.o -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo -c -o
> libc/machine/aarch64/libc_a-memrchr.o `test -f
> 'libc/machine/aarch64/memrchr.S' || echo
> '$(srcdir)/'`libc/machine/aarch64/memrchr.S
>  @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po
> @@ -32993,19 +32973,19 @@ libc/machine/aarch64/libc_a-memcpy-stub.obj:
> libc/machine/aarch64/memcpy-stub.c
>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
>  @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CFLAGS) $(CFLAGS) -c -o
> libc/machine/aarch64/libc_a-memcpy-stub.obj `if test -f
> 'libc/machine/aarch64/memcpy-stub.c'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memcpy-stub.c'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memcpy-stub.c'; fi`
>
> -libc/machine/aarch64/libc_a-memmove-stub.o:
> libc/machine/aarch64/memmove-stub.c
> -@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
> libc/machine/aarch64/libc_a-memmove-stub.o -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove-stub.o `test -f
> 'libc/machine/aarch64/memmove-stub.c' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
> -@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
> -@AMDEP_TRUE@@am__fastdepCC_FALSE@
> $(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c'
> object='libc/machine/aarch64/libc_a-memmove-stub.o' libtool=no
> @AMDEPBACKSLASH@
> +libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.c
> +@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
> libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove.o `test -f
> 'libc/machine/aarch64/memmove.c' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove.c
> +@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
> +@AMDEP_TRUE@@am__fastdepCC_FALSE@
> $(AM_V_CC)source='libc/machine/aarch64/memmove.c'
> object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
> -@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove-stub.o
> `test -f 'libc/machine/aarch64/memmove-stub.c' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
> +@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.o
> `test -f 'libc/machine/aarch64/memmove.c' || echo
> '$(srcdir)/'`libc/machine/aarch64/memmove.c
>
> -libc/machine/aarch64/libc_a-memmove-stub.obj:
> libc/machine/aarch64/memmove-stub.c
> -@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
> libc/machine/aarch64/libc_a-memmove-stub.obj -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f
> 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
> -@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
> -@AMDEP_TRUE@@am__fastdepCC_FALSE@
> $(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c'
> object='libc/machine/aarch64/libc_a-memmove-stub.obj' libtool=no
> @AMDEPBACKSLASH@
> +libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.c
> +@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
> libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
> libc/machine/aarch64/libc_a-memmove.obj `if test -f
> 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
> +@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
> +@AMDEP_TRUE@@am__fastdepCC_FALSE@
> $(AM_V_CC)source='libc/machine/aarch64/memmove.c'
> object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
> $(depcomp) @AMDEPBACKSLASH@
> -@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CFLAGS) $(CFLAGS) -c -o
> libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f
> 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
> +@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.obj
> `if test -f 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W)
> 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W)
> '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
>
>  libc/machine/aarch64/libc_a-memrchr-stub.o:
> libc/machine/aarch64/memrchr-stub.c
>  @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
> libc/machine/aarch64/libc_a-memrchr-stub.o -MD -MP -MF
> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Tpo -c -o
> libc/machine/aarch64/libc_a-memrchr-stub.o `test -f
> 'libc/machine/aarch64/memrchr-stub.c' || echo
> '$(srcdir)/'`libc/machine/aarch64/memrchr-stub.c
> diff --git a/newlib/libc/machine/aarch64/Makefile.inc
> b/newlib/libc/machine/aarch64/Makefile.inc
> index c749b0d575..1068d88ce8 100644
> --- a/newlib/libc/machine/aarch64/Makefile.inc
> +++ b/newlib/libc/machine/aarch64/Makefile.inc
> @@ -5,8 +5,7 @@ libc_a_SOURCES += \
>         %D%/memcmp.S \
>         %D%/memcpy-stub.c \
>         %D%/memcpy.S \
> -       %D%/memmove-stub.c \
> -       %D%/memmove.S \
> +       %D%/memmove.c \
>         %D%/memrchr-stub.c \
>         %D%/memrchr.S \
>         %D%/memset-stub.c \
> diff --git a/newlib/libc/machine/aarch64/memmove.S
> b/newlib/libc/machine/aarch64/memmove.S
> deleted file mode 100644
> index 597a8c8e9e..0000000000
> --- a/newlib/libc/machine/aarch64/memmove.S
> +++ /dev/null
> @@ -1,155 +0,0 @@
> -/* Copyright (c) 2013, Linaro Limited
> -   All rights reserved.
> -
> -   Redistribution and use in source and binary forms, with or without
> -   modification, are permitted provided that the following conditions are
> met:
> -       * Redistributions of source code must retain the above copyright
> -         notice, this list of conditions and the following disclaimer.
> -       * Redistributions in binary form must reproduce the above copyright
> -         notice, this list of conditions and the following disclaimer in
> the
> -         documentation and/or other materials provided with the
> distribution.
> -       * Neither the name of the Linaro nor the
> -         names of its contributors may be used to endorse or promote
> products
> -         derived from this software without specific prior written
> permission.
> -
> -   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> -   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> -   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> -   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> -   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> -   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> -   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> -   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> -   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> -   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> -   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
> -
> -/*
> - * Copyright (c) 2015 ARM Ltd
> - * All rights reserved.
> - *
> - * Redistribution and use in source and binary forms, with or without
> - * modification, are permitted provided that the following conditions
> - * are met:
> - * 1. Redistributions of source code must retain the above copyright
> - *    notice, this list of conditions and the following disclaimer.
> - * 2. Redistributions in binary form must reproduce the above copyright
> - *    notice, this list of conditions and the following disclaimer in the
> - *    documentation and/or other materials provided with the distribution.
> - * 3. The name of the company may not be used to endorse or promote
> - *    products derived from this software without specific prior written
> - *    permission.
> - *
> - * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR
> IMPLIED
> - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> - * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL,
> - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> LIMITED
> - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> - */
> -
> -/* Assumptions:
> - *
> - * ARMv8-a, AArch64, unaligned accesses
> - */
> -
> -#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
> -/* See memmove-stub.c  */
> -#else
> -
> -       .macro def_fn f p2align=0
> -       .text
> -       .p2align \p2align
> -       .global \f
> -       .type \f, %function
> -\f:
> -       .endm
> -
> -/* Parameters and result.  */
> -#define dstin  x0
> -#define src    x1
> -#define count  x2
> -#define srcend x3
> -#define dstend x4
> -#define tmp1   x5
> -#define A_l    x6
> -#define A_h    x7
> -#define B_l    x8
> -#define B_h    x9
> -#define C_l    x10
> -#define C_h    x11
> -#define D_l    x12
> -#define D_h    x13
> -#define E_l    count
> -#define E_h    tmp1
> -
> -/* All memmoves up to 96 bytes are done by memcpy as it supports overlaps.
> -   Larger backwards copies are also handled by memcpy. The only remaining
> -   case is forward large copies.  The destination is aligned, and an
> -   unrolled loop processes 64 bytes per iteration.
> -*/
> -
> -def_fn memmove, 6
> -       sub     tmp1, dstin, src
> -       cmp     count, 96
> -       ccmp    tmp1, count, 2, hi
> -       b.hs    memcpy
> -
> -       cbz     tmp1, 3f
> -       add     dstend, dstin, count
> -       add     srcend, src, count
> -
> -       /* Align dstend to 16 byte alignment so that we don't cross cache
> line
> -          boundaries on both loads and stores.  There are at least 96
> bytes
> -          to copy, so copy 16 bytes unaligned and then align.  The loop
> -          copies 64 bytes per iteration and prefetches one iteration
> ahead.  */
> -
> -       and     tmp1, dstend, 15
> -       ldp     D_l, D_h, [srcend, -16]
> -       sub     srcend, srcend, tmp1
> -       sub     count, count, tmp1
> -       ldp     A_l, A_h, [srcend, -16]
> -       stp     D_l, D_h, [dstend, -16]
> -       ldp     B_l, B_h, [srcend, -32]
> -       ldp     C_l, C_h, [srcend, -48]
> -       ldp     D_l, D_h, [srcend, -64]!
> -       sub     dstend, dstend, tmp1
> -       subs    count, count, 128
> -       b.ls    2f
> -       nop
> -1:
> -       stp     A_l, A_h, [dstend, -16]
> -       ldp     A_l, A_h, [srcend, -16]
> -       stp     B_l, B_h, [dstend, -32]
> -       ldp     B_l, B_h, [srcend, -32]
> -       stp     C_l, C_h, [dstend, -48]
> -       ldp     C_l, C_h, [srcend, -48]
> -       stp     D_l, D_h, [dstend, -64]!
> -       ldp     D_l, D_h, [srcend, -64]!
> -       subs    count, count, 64
> -       b.hi    1b
> -
> -       /* Write the last full set of 64 bytes.  The remainder is at most
> 64
> -          bytes, so it is safe to always copy 64 bytes from the start
> even if
> -          there is just 1 byte left.  */
> -2:
> -       ldp     E_l, E_h, [src, 48]
> -       stp     A_l, A_h, [dstend, -16]
> -       ldp     A_l, A_h, [src, 32]
> -       stp     B_l, B_h, [dstend, -32]
> -       ldp     B_l, B_h, [src, 16]
> -       stp     C_l, C_h, [dstend, -48]
> -       ldp     C_l, C_h, [src]
> -       stp     D_l, D_h, [dstend, -64]
> -       stp     E_l, E_h, [dstin, 48]
> -       stp     A_l, A_h, [dstin, 32]
> -       stp     B_l, B_h, [dstin, 16]
> -       stp     C_l, C_h, [dstin]
> -3:     ret
> -
> -       .size   memmove, . - memmove
> -#endif
> diff --git a/newlib/libc/machine/aarch64/memmove-stub.c
> b/newlib/libc/machine/aarch64/memmove.c
> similarity index 98%
> rename from newlib/libc/machine/aarch64/memmove-stub.c
> rename to newlib/libc/machine/aarch64/memmove.c
> index 8fa4ab9387..bc8255fb8b 100644
> --- a/newlib/libc/machine/aarch64/memmove-stub.c
> +++ b/newlib/libc/machine/aarch64/memmove.c
> @@ -27,5 +27,5 @@
>  #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
>  # include "../../string/memmove.c"
>  #else
> -/* See memmove.S  */
> +/* See memcpy.S  */
>  #endif
> --
> 2.35.3
>
>
  
Joel Sherrill Nov. 1, 2023, 7:21 p.m. UTC | #2
Sebastian's patch is OK to push.

Thanks.

--joel

On Fri, Oct 27, 2023 at 2:00 PM Joel Sherrill <joel@rtems.org> wrote:

> Based on a build and nm, memmove and memcpy are coming from the machine
> optimized version and memmove.o is empty.
>
> The patch looks like it fixes the problem.  The autotools stuff will need
> regeneration after it is pushed. I couldn't do that when I tried.
>
> If someone can push it and regenerate, that would be very much appreciated.
>
> Thanks.
>
> --joel
>
> On Fri, Oct 27, 2023 at 1:18 PM Sebastian Huber <
> sebastian.huber@embedded-brains.de> wrote:
>
>> The optimized aarch64/memcpy.S already provides a memmove()
>> implementation.
>> ---
>>
>> v2: Rename memmove-stub.c in memmove.c to make the build system happy.
>>
>>  newlib/Makefile.in                            |  42 ++---
>>  newlib/libc/machine/aarch64/Makefile.inc      |   3 +-
>>  newlib/libc/machine/aarch64/memmove.S         | 155 ------------------
>>  .../aarch64/{memmove-stub.c => memmove.c}     |   2 +-
>>  4 files changed, 13 insertions(+), 189 deletions(-)
>>  delete mode 100644 newlib/libc/machine/aarch64/memmove.S
>>  rename newlib/libc/machine/aarch64/{memmove-stub.c => memmove.c} (98%)
>>
>> diff --git a/newlib/Makefile.in b/newlib/Makefile.in
>> index 4cb3534cc4..4f0b3bf644 100644
>> --- a/newlib/Makefile.in
>> +++ b/newlib/Makefile.in
>> @@ -594,8 +594,7 @@ check_PROGRAMS =
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memcmp.S \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/memcpy-stub.c \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memcpy.S \
>> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/memmove-stub.c \
>> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memmove.S \
>> +@HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memmove.c \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/memrchr-stub.c \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@       libc/machine/aarch64/memrchr.S \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/memset-stub.c \
>> @@ -1847,7 +1846,6 @@ am__objects_51 = libc/ssp/libc_a-chk_fail.$(OBJEXT)
>> \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memcmp.$(OBJEXT) \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT) \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memcpy.$(OBJEXT) \
>> -@HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT) \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memmove.$(OBJEXT) \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memrchr-stub.$(OBJEXT) \
>>  @HAVE_LIBC_MACHINE_AARCH64_TRUE@
>>  libc/machine/aarch64/libc_a-memrchr.$(OBJEXT) \
>> @@ -8022,9 +8020,6 @@ libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT):
>> \
>>  libc/machine/aarch64/libc_a-memcpy.$(OBJEXT):  \
>>         libc/machine/aarch64/$(am__dirstamp) \
>>         libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
>> -libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT):  \
>> -       libc/machine/aarch64/$(am__dirstamp) \
>> -       libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
>>  libc/machine/aarch64/libc_a-memmove.$(OBJEXT):  \
>>         libc/machine/aarch64/$(am__dirstamp) \
>>         libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
>> @@ -12738,7 +12733,6 @@ distclean-compile:
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memcmp.Po@am__quote@
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memcpy-stub.Po@am__quote@
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memcpy.Po@am__quote@
>> -@AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po@am__quote@
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memmove.Po@am__quote@
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Po@am__quote@
>>  @AMDEP_TRUE@@am__include@ @am__quote@libc
>> /machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po@am__quote@
>> @@ -16709,20 +16703,6 @@ libc/machine/aarch64/libc_a-memcpy.obj:
>> libc/machine/aarch64/memcpy.S
>>  @AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>>  @am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
>> libc/machine/aarch64/libc_a-memcpy.obj `if test -f
>> 'libc/machine/aarch64/memcpy.S'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memcpy.S'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memcpy.S'; fi`
>>
>> -libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.S
>> -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
>> -MT libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove.o `test -f
>> 'libc/machine/aarch64/memmove.S' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove.S
>> -@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
>> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@
>> $(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S'
>> object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
>> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>> -@am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
>> libc/machine/aarch64/libc_a-memmove.o `test -f
>> 'libc/machine/aarch64/memmove.S' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove.S
>> -
>> -libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.S
>> -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
>> -MT libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove.obj `if test -f
>> 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
>> -@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
>> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@
>> $(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S'
>> object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
>> -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@    DEPDIR=$(DEPDIR) $(CCASDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>> -@am__fastdepCCAS_FALSE@        $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o
>> libc/machine/aarch64/libc_a-memmove.obj `if test -f
>> 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
>> -
>>  libc/machine/aarch64/libc_a-memrchr.o: libc/machine/aarch64/memrchr.S
>>  @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS)
>> -MT libc/machine/aarch64/libc_a-memrchr.o -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo -c -o
>> libc/machine/aarch64/libc_a-memrchr.o `test -f
>> 'libc/machine/aarch64/memrchr.S' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memrchr.S
>>  @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po
>> @@ -32993,19 +32973,19 @@ libc/machine/aarch64/libc_a-memcpy-stub.obj:
>> libc/machine/aarch64/memcpy-stub.c
>>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>>  @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CFLAGS) $(CFLAGS) -c -o
>> libc/machine/aarch64/libc_a-memcpy-stub.obj `if test -f
>> 'libc/machine/aarch64/memcpy-stub.c'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memcpy-stub.c'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memcpy-stub.c'; fi`
>>
>> -libc/machine/aarch64/libc_a-memmove-stub.o:
>> libc/machine/aarch64/memmove-stub.c
>> -@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
>> libc/machine/aarch64/libc_a-memmove-stub.o -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove-stub.o `test -f
>> 'libc/machine/aarch64/memmove-stub.c' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
>> -@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
>> -@AMDEP_TRUE@@am__fastdepCC_FALSE@
>> $(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c'
>> object='libc/machine/aarch64/libc_a-memmove-stub.o' libtool=no
>> @AMDEPBACKSLASH@
>> +libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.c
>> +@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
>> libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove.o `test -f
>> 'libc/machine/aarch64/memmove.c' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove.c
>> +@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
>> +@AMDEP_TRUE@@am__fastdepCC_FALSE@
>> $(AM_V_CC)source='libc/machine/aarch64/memmove.c'
>> object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
>>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>> -@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove-stub.o
>> `test -f 'libc/machine/aarch64/memmove-stub.c' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
>> +@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.o
>> `test -f 'libc/machine/aarch64/memmove.c' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memmove.c
>>
>> -libc/machine/aarch64/libc_a-memmove-stub.obj:
>> libc/machine/aarch64/memmove-stub.c
>> -@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
>> libc/machine/aarch64/libc_a-memmove-stub.obj -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f
>> 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
>> -@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
>> -@AMDEP_TRUE@@am__fastdepCC_FALSE@
>> $(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c'
>> object='libc/machine/aarch64/libc_a-memmove-stub.obj' libtool=no
>> @AMDEPBACKSLASH@
>> +libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.c
>> +@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
>> libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o
>> libc/machine/aarch64/libc_a-memmove.obj `if test -f
>> 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
>> +@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv)
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
>> +@AMDEP_TRUE@@am__fastdepCC_FALSE@
>> $(AM_V_CC)source='libc/machine/aarch64/memmove.c'
>> object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
>>  @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE)
>> $(depcomp) @AMDEPBACKSLASH@
>> -@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CFLAGS) $(CFLAGS) -c -o
>> libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f
>> 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
>> +@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS)
>> $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS)
>> $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.obj
>> `if test -f 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W)
>> 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W)
>> '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
>>
>>  libc/machine/aarch64/libc_a-memrchr-stub.o:
>> libc/machine/aarch64/memrchr-stub.c
>>  @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES)
>> $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT
>> libc/machine/aarch64/libc_a-memrchr-stub.o -MD -MP -MF
>> libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Tpo -c -o
>> libc/machine/aarch64/libc_a-memrchr-stub.o `test -f
>> 'libc/machine/aarch64/memrchr-stub.c' || echo
>> '$(srcdir)/'`libc/machine/aarch64/memrchr-stub.c
>> diff --git a/newlib/libc/machine/aarch64/Makefile.inc
>> b/newlib/libc/machine/aarch64/Makefile.inc
>> index c749b0d575..1068d88ce8 100644
>> --- a/newlib/libc/machine/aarch64/Makefile.inc
>> +++ b/newlib/libc/machine/aarch64/Makefile.inc
>> @@ -5,8 +5,7 @@ libc_a_SOURCES += \
>>         %D%/memcmp.S \
>>         %D%/memcpy-stub.c \
>>         %D%/memcpy.S \
>> -       %D%/memmove-stub.c \
>> -       %D%/memmove.S \
>> +       %D%/memmove.c \
>>         %D%/memrchr-stub.c \
>>         %D%/memrchr.S \
>>         %D%/memset-stub.c \
>> diff --git a/newlib/libc/machine/aarch64/memmove.S
>> b/newlib/libc/machine/aarch64/memmove.S
>> deleted file mode 100644
>> index 597a8c8e9e..0000000000
>> --- a/newlib/libc/machine/aarch64/memmove.S
>> +++ /dev/null
>> @@ -1,155 +0,0 @@
>> -/* Copyright (c) 2013, Linaro Limited
>> -   All rights reserved.
>> -
>> -   Redistribution and use in source and binary forms, with or without
>> -   modification, are permitted provided that the following conditions
>> are met:
>> -       * Redistributions of source code must retain the above copyright
>> -         notice, this list of conditions and the following disclaimer.
>> -       * Redistributions in binary form must reproduce the above
>> copyright
>> -         notice, this list of conditions and the following disclaimer in
>> the
>> -         documentation and/or other materials provided with the
>> distribution.
>> -       * Neither the name of the Linaro nor the
>> -         names of its contributors may be used to endorse or promote
>> products
>> -         derived from this software without specific prior written
>> permission.
>> -
>> -   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
>> -   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>> -   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
>> -   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
>> -   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>> -   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>> -   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
>> -   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>> -   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>> -   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
>> -   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> */
>> -
>> -/*
>> - * Copyright (c) 2015 ARM Ltd
>> - * All rights reserved.
>> - *
>> - * Redistribution and use in source and binary forms, with or without
>> - * modification, are permitted provided that the following conditions
>> - * are met:
>> - * 1. Redistributions of source code must retain the above copyright
>> - *    notice, this list of conditions and the following disclaimer.
>> - * 2. Redistributions in binary form must reproduce the above copyright
>> - *    notice, this list of conditions and the following disclaimer in the
>> - *    documentation and/or other materials provided with the
>> distribution.
>> - * 3. The name of the company may not be used to endorse or promote
>> - *    products derived from this software without specific prior written
>> - *    permission.
>> - *
>> - * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR
>> IMPLIED
>> - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
>> - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
>> - * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT,
>> INCIDENTAL,
>> - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>> LIMITED
>> - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
>> - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
>> - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
>> - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
>> - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> - */
>> -
>> -/* Assumptions:
>> - *
>> - * ARMv8-a, AArch64, unaligned accesses
>> - */
>> -
>> -#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
>> -/* See memmove-stub.c  */
>> -#else
>> -
>> -       .macro def_fn f p2align=0
>> -       .text
>> -       .p2align \p2align
>> -       .global \f
>> -       .type \f, %function
>> -\f:
>> -       .endm
>> -
>> -/* Parameters and result.  */
>> -#define dstin  x0
>> -#define src    x1
>> -#define count  x2
>> -#define srcend x3
>> -#define dstend x4
>> -#define tmp1   x5
>> -#define A_l    x6
>> -#define A_h    x7
>> -#define B_l    x8
>> -#define B_h    x9
>> -#define C_l    x10
>> -#define C_h    x11
>> -#define D_l    x12
>> -#define D_h    x13
>> -#define E_l    count
>> -#define E_h    tmp1
>> -
>> -/* All memmoves up to 96 bytes are done by memcpy as it supports
>> overlaps.
>> -   Larger backwards copies are also handled by memcpy. The only remaining
>> -   case is forward large copies.  The destination is aligned, and an
>> -   unrolled loop processes 64 bytes per iteration.
>> -*/
>> -
>> -def_fn memmove, 6
>> -       sub     tmp1, dstin, src
>> -       cmp     count, 96
>> -       ccmp    tmp1, count, 2, hi
>> -       b.hs    memcpy
>> -
>> -       cbz     tmp1, 3f
>> -       add     dstend, dstin, count
>> -       add     srcend, src, count
>> -
>> -       /* Align dstend to 16 byte alignment so that we don't cross cache
>> line
>> -          boundaries on both loads and stores.  There are at least 96
>> bytes
>> -          to copy, so copy 16 bytes unaligned and then align.  The loop
>> -          copies 64 bytes per iteration and prefetches one iteration
>> ahead.  */
>> -
>> -       and     tmp1, dstend, 15
>> -       ldp     D_l, D_h, [srcend, -16]
>> -       sub     srcend, srcend, tmp1
>> -       sub     count, count, tmp1
>> -       ldp     A_l, A_h, [srcend, -16]
>> -       stp     D_l, D_h, [dstend, -16]
>> -       ldp     B_l, B_h, [srcend, -32]
>> -       ldp     C_l, C_h, [srcend, -48]
>> -       ldp     D_l, D_h, [srcend, -64]!
>> -       sub     dstend, dstend, tmp1
>> -       subs    count, count, 128
>> -       b.ls    2f
>> -       nop
>> -1:
>> -       stp     A_l, A_h, [dstend, -16]
>> -       ldp     A_l, A_h, [srcend, -16]
>> -       stp     B_l, B_h, [dstend, -32]
>> -       ldp     B_l, B_h, [srcend, -32]
>> -       stp     C_l, C_h, [dstend, -48]
>> -       ldp     C_l, C_h, [srcend, -48]
>> -       stp     D_l, D_h, [dstend, -64]!
>> -       ldp     D_l, D_h, [srcend, -64]!
>> -       subs    count, count, 64
>> -       b.hi    1b
>> -
>> -       /* Write the last full set of 64 bytes.  The remainder is at most
>> 64
>> -          bytes, so it is safe to always copy 64 bytes from the start
>> even if
>> -          there is just 1 byte left.  */
>> -2:
>> -       ldp     E_l, E_h, [src, 48]
>> -       stp     A_l, A_h, [dstend, -16]
>> -       ldp     A_l, A_h, [src, 32]
>> -       stp     B_l, B_h, [dstend, -32]
>> -       ldp     B_l, B_h, [src, 16]
>> -       stp     C_l, C_h, [dstend, -48]
>> -       ldp     C_l, C_h, [src]
>> -       stp     D_l, D_h, [dstend, -64]
>> -       stp     E_l, E_h, [dstin, 48]
>> -       stp     A_l, A_h, [dstin, 32]
>> -       stp     B_l, B_h, [dstin, 16]
>> -       stp     C_l, C_h, [dstin]
>> -3:     ret
>> -
>> -       .size   memmove, . - memmove
>> -#endif
>> diff --git a/newlib/libc/machine/aarch64/memmove-stub.c
>> b/newlib/libc/machine/aarch64/memmove.c
>> similarity index 98%
>> rename from newlib/libc/machine/aarch64/memmove-stub.c
>> rename to newlib/libc/machine/aarch64/memmove.c
>> index 8fa4ab9387..bc8255fb8b 100644
>> --- a/newlib/libc/machine/aarch64/memmove-stub.c
>> +++ b/newlib/libc/machine/aarch64/memmove.c
>> @@ -27,5 +27,5 @@
>>  #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
>>  # include "../../string/memmove.c"
>>  #else
>> -/* See memmove.S  */
>> +/* See memcpy.S  */
>>  #endif
>> --
>> 2.35.3
>>
>>
  
Sebastian Huber Nov. 20, 2023, 2:38 p.m. UTC | #3
On 27.10.23 20:18, Sebastian Huber wrote:
> The optimized aarch64/memcpy.S already provides a memmove() implementation.
> ---
> 
> v2: Rename memmove-stub.c in memmove.c to make the build system happy.

Any objections to commit this change?
  
Corinna Vinschen Nov. 20, 2023, 8:06 p.m. UTC | #4
On Nov 20 15:38, Sebastian Huber wrote:
> On 27.10.23 20:18, Sebastian Huber wrote:
> > The optimized aarch64/memcpy.S already provides a memmove() implementation.
> > ---
> > 
> > v2: Rename memmove-stub.c in memmove.c to make the build system happy.
> 
> Any objections to commit this change?

Usually we wait for feedback from the arm guys if arm code is affected,
but I guess this should be ok.


Corinna
  
Joel Sherrill Nov. 20, 2023, 9:15 p.m. UTC | #5
On Mon, Nov 20, 2023, 2:06 PM Corinna Vinschen <vinschen@redhat.com> wrote:

> On Nov 20 15:38, Sebastian Huber wrote:
> > On 27.10.23 20:18, Sebastian Huber wrote:
> > > The optimized aarch64/memcpy.S already provides a memmove()
> implementation.
> > > ---
> > >
> > > v2: Rename memmove-stub.c in memmove.c to make the build system happy.
> >
> > Any objections to commit this change?
>
> Usually we wait for feedback from the arm guys if arm code is affected,
> but I guess this should be ok.
>

This is really just to account for the newlib build system assuming machine
specific methods override at the file name level. This fixes where two
methods were in the same assembly file but it didn't override the default
of one of them.

I don't think the arm guys care about newlib build machinery. :)

--joel

>
>
> Corinna
>
>
  

Patch

diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 4cb3534cc4..4f0b3bf644 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -594,8 +594,7 @@  check_PROGRAMS =
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memcmp.S \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memcpy-stub.c \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memcpy.S \
-@HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memmove-stub.c \
-@HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memmove.S \
+@HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memmove.c \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memrchr-stub.c \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memrchr.S \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/memset-stub.c \
@@ -1847,7 +1846,6 @@  am__objects_51 = libc/ssp/libc_a-chk_fail.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memcmp.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memcpy.$(OBJEXT) \
-@HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memmove.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memrchr-stub.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-memrchr.$(OBJEXT) \
@@ -8022,9 +8020,6 @@  libc/machine/aarch64/libc_a-memcpy-stub.$(OBJEXT):  \
 libc/machine/aarch64/libc_a-memcpy.$(OBJEXT):  \
 	libc/machine/aarch64/$(am__dirstamp) \
 	libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
-libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT):  \
-	libc/machine/aarch64/$(am__dirstamp) \
-	libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
 libc/machine/aarch64/libc_a-memmove.$(OBJEXT):  \
 	libc/machine/aarch64/$(am__dirstamp) \
 	libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp)
@@ -12738,7 +12733,6 @@  distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memcmp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memcpy-stub.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memcpy.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po@am__quote@
@@ -16709,20 +16703,6 @@  libc/machine/aarch64/libc_a-memcpy.obj: libc/machine/aarch64/memcpy.S
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCCAS_FALSE@	$(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memcpy.obj `if test -f 'libc/machine/aarch64/memcpy.S'; then $(CYGPATH_W) 'libc/machine/aarch64/memcpy.S'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memcpy.S'; fi`
 
-libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.S
-@am__fastdepCCAS_TRUE@	$(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -MT libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o libc/machine/aarch64/libc_a-memmove.o `test -f 'libc/machine/aarch64/memmove.S' || echo '$(srcdir)/'`libc/machine/aarch64/memmove.S
-@am__fastdepCCAS_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
-@AMDEP_TRUE@@am__fastdepCCAS_FALSE@	$(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S' object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCCAS_FALSE@	$(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.o `test -f 'libc/machine/aarch64/memmove.S' || echo '$(srcdir)/'`libc/machine/aarch64/memmove.S
-
-libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.S
-@am__fastdepCCAS_TRUE@	$(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -MT libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o libc/machine/aarch64/libc_a-memmove.obj `if test -f 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
-@am__fastdepCCAS_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
-@AMDEP_TRUE@@am__fastdepCCAS_FALSE@	$(AM_V_CPPAS)source='libc/machine/aarch64/memmove.S' object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCCAS_FALSE@	$(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.obj `if test -f 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove.S'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove.S'; fi`
-
 libc/machine/aarch64/libc_a-memrchr.o: libc/machine/aarch64/memrchr.S
 @am__fastdepCCAS_TRUE@	$(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAGS) -MT libc/machine/aarch64/libc_a-memrchr.o -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo -c -o libc/machine/aarch64/libc_a-memrchr.o `test -f 'libc/machine/aarch64/memrchr.S' || echo '$(srcdir)/'`libc/machine/aarch64/memrchr.S
 @am__fastdepCCAS_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po
@@ -32993,19 +32973,19 @@  libc/machine/aarch64/libc_a-memcpy-stub.obj: libc/machine/aarch64/memcpy-stub.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memcpy-stub.obj `if test -f 'libc/machine/aarch64/memcpy-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/memcpy-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memcpy-stub.c'; fi`
 
-libc/machine/aarch64/libc_a-memmove-stub.o: libc/machine/aarch64/memmove-stub.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/aarch64/libc_a-memmove-stub.o -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o libc/machine/aarch64/libc_a-memmove-stub.o `test -f 'libc/machine/aarch64/memmove-stub.c' || echo '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c' object='libc/machine/aarch64/libc_a-memmove-stub.o' libtool=no @AMDEPBACKSLASH@
+libc/machine/aarch64/libc_a-memmove.o: libc/machine/aarch64/memmove.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/aarch64/libc_a-memmove.o -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o libc/machine/aarch64/libc_a-memmove.o `test -f 'libc/machine/aarch64/memmove.c' || echo '$(srcdir)/'`libc/machine/aarch64/memmove.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/aarch64/memmove.c' object='libc/machine/aarch64/libc_a-memmove.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove-stub.o `test -f 'libc/machine/aarch64/memmove-stub.c' || echo '$(srcdir)/'`libc/machine/aarch64/memmove-stub.c
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.o `test -f 'libc/machine/aarch64/memmove.c' || echo '$(srcdir)/'`libc/machine/aarch64/memmove.c
 
-libc/machine/aarch64/libc_a-memmove-stub.obj: libc/machine/aarch64/memmove-stub.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/aarch64/libc_a-memmove-stub.obj -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo -c -o libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove-stub.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/aarch64/memmove-stub.c' object='libc/machine/aarch64/libc_a-memmove-stub.obj' libtool=no @AMDEPBACKSLASH@
+libc/machine/aarch64/libc_a-memmove.obj: libc/machine/aarch64/memmove.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/aarch64/libc_a-memmove.obj -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo -c -o libc/machine/aarch64/libc_a-memmove.obj `if test -f 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memmove.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/aarch64/memmove.c' object='libc/machine/aarch64/libc_a-memmove.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f 'libc/machine/aarch64/memmove-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove-stub.c'; fi`
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.obj `if test -f 'libc/machine/aarch64/memmove.c'; then $(CYGPATH_W) 'libc/machine/aarch64/memmove.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove.c'; fi`
 
 libc/machine/aarch64/libc_a-memrchr-stub.o: libc/machine/aarch64/memrchr-stub.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/aarch64/libc_a-memrchr-stub.o -MD -MP -MF libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stub.Tpo -c -o libc/machine/aarch64/libc_a-memrchr-stub.o `test -f 'libc/machine/aarch64/memrchr-stub.c' || echo '$(srcdir)/'`libc/machine/aarch64/memrchr-stub.c
diff --git a/newlib/libc/machine/aarch64/Makefile.inc b/newlib/libc/machine/aarch64/Makefile.inc
index c749b0d575..1068d88ce8 100644
--- a/newlib/libc/machine/aarch64/Makefile.inc
+++ b/newlib/libc/machine/aarch64/Makefile.inc
@@ -5,8 +5,7 @@  libc_a_SOURCES += \
 	%D%/memcmp.S \
 	%D%/memcpy-stub.c \
 	%D%/memcpy.S \
-	%D%/memmove-stub.c \
-	%D%/memmove.S \
+	%D%/memmove.c \
 	%D%/memrchr-stub.c \
 	%D%/memrchr.S \
 	%D%/memset-stub.c \
diff --git a/newlib/libc/machine/aarch64/memmove.S b/newlib/libc/machine/aarch64/memmove.S
deleted file mode 100644
index 597a8c8e9e..0000000000
--- a/newlib/libc/machine/aarch64/memmove.S
+++ /dev/null
@@ -1,155 +0,0 @@ 
-/* Copyright (c) 2013, Linaro Limited
-   All rights reserved.
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-       * Redistributions of source code must retain the above copyright
-         notice, this list of conditions and the following disclaimer.
-       * Redistributions in binary form must reproduce the above copyright
-         notice, this list of conditions and the following disclaimer in the
-         documentation and/or other materials provided with the distribution.
-       * Neither the name of the Linaro nor the
-         names of its contributors may be used to endorse or promote products
-         derived from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
-
-/*
- * Copyright (c) 2015 ARM Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Assumptions:
- *
- * ARMv8-a, AArch64, unaligned accesses
- */
-
-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
-/* See memmove-stub.c  */
-#else
-
-	.macro def_fn f p2align=0
-	.text
-	.p2align \p2align
-	.global \f
-	.type \f, %function
-\f:
-	.endm
-
-/* Parameters and result.  */
-#define dstin	x0
-#define src	x1
-#define count	x2
-#define srcend	x3
-#define dstend	x4
-#define tmp1	x5
-#define A_l	x6
-#define A_h	x7
-#define B_l	x8
-#define B_h	x9
-#define C_l	x10
-#define C_h	x11
-#define D_l	x12
-#define D_h	x13
-#define E_l	count
-#define E_h	tmp1
-
-/* All memmoves up to 96 bytes are done by memcpy as it supports overlaps.
-   Larger backwards copies are also handled by memcpy. The only remaining
-   case is forward large copies.  The destination is aligned, and an
-   unrolled loop processes 64 bytes per iteration.
-*/
-
-def_fn memmove, 6
-	sub	tmp1, dstin, src
-	cmp	count, 96
-	ccmp	tmp1, count, 2, hi
-	b.hs	memcpy
-
-	cbz	tmp1, 3f
-	add	dstend, dstin, count
-	add	srcend, src, count
-
-	/* Align dstend to 16 byte alignment so that we don't cross cache line
-	   boundaries on both loads and stores.	 There are at least 96 bytes
-	   to copy, so copy 16 bytes unaligned and then align.	The loop
-	   copies 64 bytes per iteration and prefetches one iteration ahead.  */
-
-	and	tmp1, dstend, 15
-	ldp	D_l, D_h, [srcend, -16]
-	sub	srcend, srcend, tmp1
-	sub	count, count, tmp1
-	ldp	A_l, A_h, [srcend, -16]
-	stp	D_l, D_h, [dstend, -16]
-	ldp	B_l, B_h, [srcend, -32]
-	ldp	C_l, C_h, [srcend, -48]
-	ldp	D_l, D_h, [srcend, -64]!
-	sub	dstend, dstend, tmp1
-	subs	count, count, 128
-	b.ls	2f
-	nop
-1:
-	stp	A_l, A_h, [dstend, -16]
-	ldp	A_l, A_h, [srcend, -16]
-	stp	B_l, B_h, [dstend, -32]
-	ldp	B_l, B_h, [srcend, -32]
-	stp	C_l, C_h, [dstend, -48]
-	ldp	C_l, C_h, [srcend, -48]
-	stp	D_l, D_h, [dstend, -64]!
-	ldp	D_l, D_h, [srcend, -64]!
-	subs	count, count, 64
-	b.hi	1b
-
-	/* Write the last full set of 64 bytes.	 The remainder is at most 64
-	   bytes, so it is safe to always copy 64 bytes from the start even if
-	   there is just 1 byte left.  */
-2:
-	ldp	E_l, E_h, [src, 48]
-	stp	A_l, A_h, [dstend, -16]
-	ldp	A_l, A_h, [src, 32]
-	stp	B_l, B_h, [dstend, -32]
-	ldp	B_l, B_h, [src, 16]
-	stp	C_l, C_h, [dstend, -48]
-	ldp	C_l, C_h, [src]
-	stp	D_l, D_h, [dstend, -64]
-	stp	E_l, E_h, [dstin, 48]
-	stp	A_l, A_h, [dstin, 32]
-	stp	B_l, B_h, [dstin, 16]
-	stp	C_l, C_h, [dstin]
-3:	ret
-
-	.size	memmove, . - memmove
-#endif
diff --git a/newlib/libc/machine/aarch64/memmove-stub.c b/newlib/libc/machine/aarch64/memmove.c
similarity index 98%
rename from newlib/libc/machine/aarch64/memmove-stub.c
rename to newlib/libc/machine/aarch64/memmove.c
index 8fa4ab9387..bc8255fb8b 100644
--- a/newlib/libc/machine/aarch64/memmove-stub.c
+++ b/newlib/libc/machine/aarch64/memmove.c
@@ -27,5 +27,5 @@ 
 #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
 # include "../../string/memmove.c"
 #else
-/* See memmove.S  */
+/* See memcpy.S  */
 #endif