public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Cc: nd <nd@arm.com>
Subject: [PATCH][AArch64] Inline mempcpy again
Date: Thu, 29 Jun 2017 16:21:00 -0000	[thread overview]
Message-ID: <AM5PR0802MB2610223EAFFF5D9F3CC5378E83D20@AM5PR0802MB2610.eurprd08.prod.outlook.com> (raw)

Recent changes removed the generic mempcpy inline.  Given GCC still
doesn't optimize mempcpy (PR70140), I am adding it again.  Since
string/string.h no longer includes an architecture specific header, do this
inside include/string.h and for now only on AArch64.

OK for commit?

ChangeLog: 
2017-06-29  Wilco Dijkstra  <wdijkstr@arm.com>

        * include/string.h: (mempcpy): Redirect to __mempcpy_inline.  
        (__mempcpy): Likewise.
        (__mempcpy_inline): New inline function.
        * sysdeps/aarch64/string_private.h: Define _INLINE_mempcpy.

--
diff --git a/include/string.h b/include/string.h
index 069efd0b87010e5fdb64c87ced7af1dc4f54f232..46b90b8f346149f075fad026e562dfb27b658969 100644
--- a/include/string.h
+++ b/include/string.h
@@ -197,4 +197,23 @@ extern char *__strncat_chk (char *__restrict __dest,
 			    size_t __len, size_t __destlen) __THROW;
 #endif
 
+#if defined __USE_GNU && defined __OPTIMIZE__ \
+    && defined __extern_always_inline && __GNUC_PREREQ (3,2) \
+    && defined _INLINE_mempcpy
+
+#undef mempcpy
+#undef __mempcpy
+
+#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
+#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
+
+__extern_always_inline void *
+__mempcpy_inline (void *__restrict __dest,
+		  const void *__restrict __src, size_t __n)
+{
+  return (char *) memcpy (__dest, __src, __n) + __n;
+}
+
+#endif
+
 #endif
diff --git a/sysdeps/aarch64/string_private.h b/sysdeps/aarch64/string_private.h
index 09dedbf3db40cf06077a44af992b399a6b37b48d..8b8fdddcc17a3f69455e72efe9c3616d2d33abe2 100644
--- a/sysdeps/aarch64/string_private.h
+++ b/sysdeps/aarch64/string_private.h
@@ -18,3 +18,6 @@
 
 /* AArch64 implementations support efficient unaligned access.  */
 #define _STRING_ARCH_unaligned 1
+
+/* Inline mempcpy since GCC doesn't optimize it (PR70140).  */
+#define _INLINE_mempcpy 1

             reply	other threads:[~2017-06-29 16:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 16:21 Wilco Dijkstra [this message]
2018-06-29 14:48 ` Wilco Dijkstra
2018-07-05 13:03 ` Adhemerval Zanella
2018-07-06  5:35   ` Siddhesh Poyarekar
2018-07-06 12:48     ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM5PR0802MB2610223EAFFF5D9F3CC5378E83D20@AM5PR0802MB2610.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).