Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/819295/?format=api
{ "id": 819295, "url": "http://patchwork.ozlabs.org/api/patches/819295/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/1506542999-97895-4-git-send-email-patrick.mcgehearty@oracle.com/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1506542999-97895-4-git-send-email-patrick.mcgehearty@oracle.com>", "list_archive_url": null, "date": "2017-09-27T20:09:59", "name": "[3/3] sparc: M7 optimized memcpy/mempcpy/memmove/memset/bzero.", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "765e02ff169396e808bea5c4ad45d947573efb2e", "submitter": { "id": 72081, "url": "http://patchwork.ozlabs.org/api/people/72081/?format=api", "name": "Patrick McGehearty", "email": "patrick.mcgehearty@oracle.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/1506542999-97895-4-git-send-email-patrick.mcgehearty@oracle.com/mbox/", "series": [ { "id": 5435, "url": "http://patchwork.ozlabs.org/api/series/5435/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=5435", "date": "2017-09-27T20:09:56", "name": "sparc M7 optimized memcpy/memset", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/5435/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/819295/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/819295/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-return-85040-incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list libc-alpha@sourceware.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-85040-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"SNc2TiBr\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y2TTk4Tl2z9t66\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 06:10:50 +1000 (AEST)", "(qmail 124575 invoked by alias); 27 Sep 2017 20:10:18 -0000", "(qmail 124431 invoked by uid 89); 27 Sep 2017 20:10:18 -0000" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=mhEbLkYhiTcioByNrH5NWKEChR2hZzD\n\tZ90bu+Zzg84Pck7BWEoGSXQSTKaB+i7ZY6IX61JRg/T+gytrJ9alCQZnScG1X1vl\n\teF74CDUswMUHK0UzVSafuADe7+zExp7/jqyvKFZOdCw8/sIZ+RpAqfXu5iYVWyEt\n\tV2a/Wgn7YgPk=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=IwdEJf5cORP86JhzpyQBcsxPmKE=; b=SNc2T\n\tiBr3CVRSVWzpTR8LS5r3MIA1khW/apcZRiY5d9+t9cja420Vvi+mvyU1esn6+Q26\n\tqD3hD3tqqSD2DCoMA1i/+UC/F668RcF0++uQ3EU8ZXqcvawFAj/TlrGn4bfxXwPq\n\t7T0xry0ilX49q3gPjBRA5UQJZ5/kZdSsfhJqlg=", "Mailing-List": "contact libc-alpha-help@sourceware.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<libc-alpha.sourceware.org>", "List-Unsubscribe": "<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>", "List-Subscribe": "<mailto:libc-alpha-subscribe@sourceware.org>", "List-Archive": "<http://sourceware.org/ml/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>", "Sender": "libc-alpha-owner@sourceware.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-23.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, UNPARSEABLE_RELAY,\n\tUNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=bis, 020,\n\tdelays, Primary", "X-HELO": "userp1040.oracle.com", "From": "Patrick McGehearty <patrick.mcgehearty@oracle.com>", "To": "libc-alpha@sourceware.org", "Subject": "[PATCH 3/3] sparc: M7 optimized memcpy/mempcpy/memmove/memset/bzero.", "Date": "Wed, 27 Sep 2017 16:09:59 -0400", "Message-Id": "<1506542999-97895-4-git-send-email-patrick.mcgehearty@oracle.com>", "In-Reply-To": "<1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com>", "References": "<1506542999-97895-1-git-send-email-patrick.mcgehearty@oracle.com>\n\t<1506542999-97895-2-git-send-email-patrick.mcgehearty@oracle.com>\n\t<1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com>" }, "content": "Tested in sparcv9-*-* and sparc64-*-* targets in both multi and\nnon-multi arch configurations.\n\nSupport added to identify Sparc M7/T7/S7/M8/T8 processor capability.\nUsual \"make check\" correctness tests run with no regressions.\nPerformance tests run on Sparc S7 using new code and old niagara4 code.\n\nOptimizations for memcpy also apply to mempcpy and memmove\nwhere they share code. Optimizations for memset also apply\nto bzero as they share code.\n\nFor memcpy/mempcpy/memmove, performance comparison with niagara4 code:\nLong word aligned data\n 0-127 bytes - minimal changes\n 128-1023 bytes - 7-30% gain\n 1024+ bytes - 1-7% gain (in cache); 30-100% gain (out of cache)\nWord aligned data\n 0-127 bytes - 50%+ gain\n 128-1023 bytes - 10-200% gain\n 1024+ bytes - 0-15% gain (in cache); 5-50% gain (out of cache)\nUnaligned data\n 0-127 bytes - 0-70%+ gain\n 128-447 bytes - 40-80%+ gain\n 448-511 bytes - 1-3% loss\n 512-4096 bytes - 2-3% gain (in cache); 0-20% gain (out of cache)\n 4096+ bytes - +/- 3% (in cache); 20-50% gain (out of cache)\n\nFor memset/bzero, performance comparison with niagara4 code:\nFor memset nonzero data,\n 256-1023 bytes - 60-90% gain (in cache); 5% gain (out of cache)\n 1K+ bytes - 80-260% gain (in cache); 40-80% gain (out of cache)\nFor memset zero data (and bzero),\n 256-1023 bytes - 80-120% gain (in cache), 0% gain (out of cache)\n 1024+ bytes - 2-4x gain (in cache), 10-35% gain (out of cache)\n---\n ChangeLog | 20 +\n sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile | 3 +-\n .../sparcv9/multiarch/memcpy-memmove-niagara7.S | 2 +\n sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S | 2 +\n .../sparc32/sparcv9/multiarch/memset-niagara7.S | 2 +\n .../sparc/sparc32/sparcv9/multiarch/rtld-memmove.c | 1 +\n sysdeps/sparc/sparc64/multiarch/Makefile | 3 +-\n sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c | 13 +\n .../sparc64/multiarch/memcpy-memmove-niagara7.S | 979 ++++++++++++++++++++\n sysdeps/sparc/sparc64/multiarch/memcpy.S | 28 +-\n sysdeps/sparc/sparc64/multiarch/memmove.S | 72 ++\n sysdeps/sparc/sparc64/multiarch/memset-niagara7.S | 334 +++++++\n sysdeps/sparc/sparc64/multiarch/memset.S | 28 +-\n sysdeps/sparc/sparc64/multiarch/rtld-memmove.c | 1 +\n 14 files changed, 1482 insertions(+), 6 deletions(-)\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-memmove-niagara7.S\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-memmove.c\n create mode 100644 sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S\n create mode 100644 sysdeps/sparc/sparc64/multiarch/memmove.S\n create mode 100644 sysdeps/sparc/sparc64/multiarch/memset-niagara7.S\n create mode 100644 sysdeps/sparc/sparc64/multiarch/rtld-memmove.c", "diff": "diff --git a/ChangeLog b/ChangeLog\nindex ee70dde..4c9d78a 100644\n--- a/ChangeLog\n+++ b/ChangeLog\n@@ -1,5 +1,25 @@\n 2017-09-26 Jose E. Marchesi <jose.marchesi@oracle.com>\n \n+\t* sysdeps/sparc/sparc64/multiarch/memset-niagara7.S: New file.\n+\t* sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S:\n+\tLikewise.\n+\t* sysdeps/sparc/sparc64/multiarch/memmove.S: Likewise.\n+\t* sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S: Likewise.\n+\t* sysdeps/sparc/sparc64/multiarch/memcpy.S: Use __memcpy_niagara7\n+\tand __mempcpy_niagara7 if the ADP hw capability is present.\n+\t* sysdeps/sparc/sparc64/multiarch/memset.S: Likewise for memset\n+\tand bzero.\n+\t* sysdeps/sparc/sparc64/multiarch/Makefile (sysdep_routines):\n+\tAdded memcpy-memmove-niagara7 and memset-niagara7.\n+\t* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile\n+\t(sysdep_routines): Likewise.\n+\t* sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S: Likewise.\n+\t* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c\n+\t(__libc_ifunc_impl_list): Added the memmove, bcopy, memcpy,\n+\tmempcpy, memset and bzero M7 implementations.\n+\n+2017-09-26 Jose E. Marchesi <jose.marchesi@oracle.com>\n+\n \t* sysdeps/sparc/sparc32/sparcv9/memmove.S: New file.\n \t* sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c: Likewise.\n \t* sysdeps/sparc/sparc64/memmove.S: Likewise.\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile\nindex 4ad7aff..0ad3e5b 100644\n--- a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile\n+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile\n@@ -8,5 +8,6 @@ endif\n \n ifeq ($(subdir),string)\n sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \\\n-\t\t memset-niagara1 memcpy-niagara4 memset-niagara4\n+\t\t memset-niagara1 memcpy-niagara4 memset-niagara4 \\\n+ memset-niagara7 memcpy-memmove-niagara7\n endif\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-memmove-niagara7.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-memmove-niagara7.S\nnew file mode 100644\nindex 0000000..16da150\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-memmove-niagara7.S\n@@ -0,0 +1,2 @@\n+#define XCC icc\n+#include <sparc64/multiarch/memcpy-memmove-niagara7.S>\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S\nnew file mode 100644\nindex 0000000..08597ba\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memmove.S\n@@ -0,0 +1,2 @@\n+#define XCC icc\n+#include <sparc64/multiarch/memmove.S>\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S\nnew file mode 100644\nindex 0000000..de91aa4\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S\n@@ -0,0 +1,2 @@\n+#define XCC icc\n+#include <sparc64/multiarch/memset-niagara7.S>\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-memmove.c b/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-memmove.c\nnew file mode 100644\nindex 0000000..2c88061\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-memmove.c\n@@ -0,0 +1 @@\n+#include <sparc64/multiarch/rtld-memmove.c>\ndiff --git a/sysdeps/sparc/sparc64/multiarch/Makefile b/sysdeps/sparc/sparc64/multiarch/Makefile\nindex 55b757f..271c57a 100644\n--- a/sysdeps/sparc/sparc64/multiarch/Makefile\n+++ b/sysdeps/sparc/sparc64/multiarch/Makefile\n@@ -8,7 +8,8 @@ endif\n \n ifeq ($(subdir),string)\n sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \\\n-\t\t memset-niagara1 memcpy-niagara4 memset-niagara4\n+\t\t memset-niagara1 memcpy-niagara4 memset-niagara4 \\\n+ memset-niagara7 memcpy-memmove-niagara7\n endif\n \n ifeq ($(subdir),stdlib)\ndiff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c\nindex a97bc45..cc85dd0 100644\n--- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c\n+++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c\n@@ -36,6 +36,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,\n hwcap = GLRO(dl_hwcap);\n \n IFUNC_IMPL (i, name, memcpy,\n+ IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_ADP,\n+ __memcpy_niagara7)\n \t IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_CRYPTO,\n \t\t\t __memcpy_niagara4)\n \t IFUNC_IMPL_ADD (array, i, memcpy, hwcap & HWCAP_SPARC_N2,\n@@ -47,6 +49,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,\n \t IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ultra1));\n \n IFUNC_IMPL (i, name, mempcpy,\n+ IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_ADP,\n+ __mempcpy_niagara7)\n \t IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_CRYPTO,\n \t\t\t __mempcpy_niagara4)\n \t IFUNC_IMPL_ADD (array, i, mempcpy, hwcap & HWCAP_SPARC_N2,\n@@ -58,6 +62,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,\n \t IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_ultra1));\n \n IFUNC_IMPL (i, name, bzero,\n+ IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_ADP,\n+ __bzero_niagara7)\n \t IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_CRYPTO,\n \t\t\t __bzero_niagara4)\n \t IFUNC_IMPL_ADD (array, i, bzero, hwcap & HWCAP_SPARC_BLKINIT,\n@@ -65,11 +71,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,\n \t IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ultra1));\n \n IFUNC_IMPL (i, name, memset,\n+ IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_ADP,\n+ __memset_niagara7)\n \t IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_CRYPTO,\n \t\t\t __memset_niagara4)\n \t IFUNC_IMPL_ADD (array, i, memset, hwcap & HWCAP_SPARC_BLKINIT,\n \t\t\t __memset_niagara1)\n \t IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ultra1));\n \n+ IFUNC_IMPL (i, name, memmove,\n+ IFUNC_IMPL_ADD (array, i, memmove, hwcap & HWCAP_SPARC_ADP,\n+ __memmove_niagara7)\n+ IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ultra1));\n+\n return i;\n }\ndiff --git a/sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S b/sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S\nnew file mode 100644\nindex 0000000..a8c34a9\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S\n@@ -0,0 +1,979 @@\n+/* Copy SIZE bytes from SRC to DEST. For SUN4V M7.\n+ Copyright (C) 2017 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, see\n+ <http://www.gnu.org/licenses/>. */\n+\n+#include <sysdep.h>\n+\n+#ifndef XCC\n+# define XCC xcc\n+#endif\n+\t.register\t%g2,#scratch\n+\t.register\t%g3,#scratch\n+\t.register\t%g6,#scratch\n+\n+#define\tFPRS_FEF\t0x04\n+\n+/*\n+ * ASI_STBI_P marks the cache line as \"least recently used\"\n+ * which means if many threads are active, it has a high chance\n+ * of being pushed out of the cache between the first initializing\n+ * store and the final stores.\n+ * Thus, in this algorithm we use ASI_STBIMRU_P which marks the\n+ * cache line as \"most recently used\" for all but the last cache\n+ * line.\n+ */\n+\n+#define\tASI_BLK_INIT_QUAD_LDD_P\t0xe2\n+#define\tASI_ST_BLK_INIT_MRU_P\t0xf2\n+\n+#define\tASI_STBI_P\tASI_BLK_INIT_QUAD_LDD_P\n+#define\tASI_STBIMRU_P\tASI_ST_BLK_INIT_MRU_P\n+\n+#define\tBLOCK_SIZE\t64\t/* L2 data cache line size */\n+#define\tSHORTCOPY\t3\n+#define\tSHORTCHECK\t14\n+#define\tSHORT_LONG\t64\t/* max copy for short longword-aligned case */\n+\t\t\t\t/* must be at least 64 */\n+#define\tSMALL_MAX\t255\t/* max small copy for word/long aligned */\n+#define\tSMALL_UMAX\t128\t/* max small copy for unaligned case */\n+#define\tMED_WMAX\t1023\t/* max copy for medium word-aligned case */\n+#define\tMED_MAX\t\t511\t/* max copy for medium longword-aligned case */\n+#define\tST_CHUNK\t20\t/* ST_CHUNK - block of values for BIS Store */\n+/* on T4, prefetch 20 is a strong read prefetch to L1 and L2 data cache\n+ * prefetch 20 can cause inst pipeline to delay if data is in memory\n+ * prefetch 21 is a strong read prefetch to L2 data cache, not L1 data cache */\n+#define\tALIGN_PRE\t20\t/* distance for aligned prefetch loop */\n+\n+#define EX_ST(x)\tx\n+#define EX_RETVAL(x)\tx\n+#define STORE_ASI(src,addr)\tstxa src, [addr] ASI_STBIMRU_P\n+#define STORE_INIT(src,addr)\tstxa src, [addr] ASI_STBI_P\n+\n+#if IS_IN (libc)\n+\n+\t.text\n+\n+ENTRY(__memmove_niagara7)\n+\t/* %o0=dst, %o1=src, %o2=len */\n+\tcmp\t%o1, %o0\t/* if from address is >= to use forward copy */\n+\tbgeu,pn\t%XCC, .Lforcpy\t/* else use backward if ... */\n+\t sub\t%o0, %o1, %o4\t/* get difference of two addresses */\n+\tcmp\t%o2, %o4\t/* compare size and difference of addresses */\n+\tbleu,pn\t%XCC, .Lforcpy\t/* if size is bigger, do overlapped copy */\n+\t add\t%o1, %o2, %o5\t/* get to end of source space */\n+\n+/* an overlapped copy that must be done \"backwards\" */\n+.Lchksize:\n+\tcmp\t%o2, 8\t\t\t/* less than 8 byte do byte copy */\n+\tblu,pn %XCC, 2f\t\t\t/* else continue */\n+\n+/* Now size is bigger than 8 */\n+.Ldbalign:\n+\t add\t%o0, %o2, %g1\t\t/* get to end of dest space */\n+\tandcc\t%g1, 7, %o3\t\t/* %o3 has cnt til dst 8 byte align */\n+\tbz,a,pn\t%XCC, .Ldbbck\t\t/* skip if dst is 8 byte aligned */\n+\t andn\t%o2, 7, %o3\t\t/* force %o3 cnt to multiple of 8 */\n+\tsub\t%o2, %o3, %o2\t\t/* update o2 with new count */\n+\n+1:\tdec\t%o5\t\t\t/* decrement source */\n+\tldub\t[%o5], %g1\t\t/* load one byte */\n+\tdeccc\t%o3\t\t\t/* decrement count */\n+\tbgu,pt\t%XCC, 1b\t\t/* if not done keep copying */\n+\t stb\t%g1, [%o5+%o4]\t\t/* store one byte into dest */\n+\tandncc\t%o2, 7, %o3\t\t/* force %o3 cnt to multiple of 8 */\n+\tbz,pn\t%XCC, 2f\t\t/* if size < 8, move to byte copy */\n+\n+/* Now Destination is 8 byte aligned */\n+.Ldbbck:\n+\t andcc\t%o5, 7, %o0\t\t/* %o0 has src offset */\n+\tbz,a,pn\t%XCC, .Ldbcopybc\t/* if src is aligned do fast memmove */\n+\t sub\t%o2, %o3, %o2\t\t/* Residue bytes in %o2 */\n+\n+.Lcpy_dbwdbc:\t\t\t\t/* alignment of src is needed */\n+\tsub\t%o2, 8, %o2\t\t/* set size one loop ahead */\n+\tsll\t%o0, 3, %g1\t\t/* %g1 is left shift */\n+\tmov\t64, %g5\t\t\t/* init %g5 to be 64 */\n+\tsub\t%g5, %g1, %g5\t\t/* %g5 rightshift = (64 - leftshift) */\n+\tsub\t%o5, %o0, %o5\t\t/* align the src at 8 bytes. */\n+\tadd\t%o4, %o0, %o4\t\t/* increase diff between src & dst */\n+\tldx\t[%o5], %o1\t\t/* load first 8 bytes */\n+\tsrlx\t%o1, %g5, %o1\n+1:\tsub\t%o5, 8, %o5\t\t/* subtract 8 from src */\n+\tldx\t[%o5], %o0\t\t/* load 8 byte */\n+\tsllx\t%o0, %g1, %o3\t\t/* shift loaded val left to tmp reg */\n+\tor\t%o1, %o3, %o3\t\t/* align data */\n+\tstx\t%o3, [%o5+%o4]\t\t/* store 8 byte */\n+\tsubcc\t%o2, 8, %o2\t\t/* subtract 8 byte from size */\n+\tbg,pt\t%XCC, 1b\t\t/* if size > 0 continue */\n+\t srlx\t%o0, %g5, %o1\t\t/* move extra byte for the next use */\n+\n+\tsrl\t%g1, 3, %o0\t\t/* restore %o0 value for alignment */\n+\tadd\t%o5, %o0, %o5\t\t/* restore src alignment */\n+\tsub\t%o4, %o0, %o4\t\t/* restore diff between src & dest */\n+\n+\tba\t2f\t\t\t/* branch to the trailing byte copy */\n+\t add\t%o2, 8, %o2\t\t/* restore size value */\n+\n+.Ldbcopybc:\t\t\t\t/* alignment of src is not needed */\n+1:\tsub\t%o5, 8, %o5\t\t/* subtract from src */\n+\tldx\t[%o5], %g1\t\t/* load 8 bytes */\n+\tsubcc\t%o3, 8, %o3\t\t/* subtract from size */\n+\tbgu,pt\t%XCC, 1b\t\t/* if size is bigger 0 continue */\n+\t stx\t%g1, [%o5+%o4]\t\t/* store 8 bytes to destination */\n+\n+\tba\t2f\n+\t nop\n+\n+.Lbcbyte:\n+1:\tldub\t[%o5], %g1\t\t/* load one byte */\n+\tstb\t%g1, [%o5+%o4]\t\t/* store one byte */\n+2:\tdeccc\t%o2\t\t\t/* decrement size */\n+\tbgeu,a,pt %XCC, 1b\t\t/* if size is >= 0 continue */\n+\t dec\t%o5\t\t\t/* decrement from address */\n+\n+.Lexitbc:\t\t\t\t/* exit from backward copy */\n+\tretl\n+\t add\t%o5, %o4, %o0\t\t/* restore dest addr */\n+\n+\n+/* Check to see if memmove is large aligned copy\n+ * If so, use special version of copy that avoids\n+ * use of block store init. */\n+.Lforcpy:\n+\tcmp\t%o2, SMALL_MAX\t\t/* check for not small case */\n+\tblt,pn\t%XCC, .Lmv_short\t/* merge with memcpy */\n+\t mov\t%o0, %g1\t\t/* save %o0 */\n+\tneg\t%o0, %o5\n+\tandcc\t%o5, 7, %o5\t\t/* bytes till DST 8 byte aligned */\n+\tbrz,pt\t%o5, .Lmv_dst_aligned_on_8\n+\n+/* %o5 has the bytes to be written in partial store. */\n+\t sub\t%o2, %o5, %o2\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+7:\t\t\t\t\t/* dst aligning loop */\n+\tldub\t[%o1+%o0], %o4\t\t/* load one byte */\n+\tsubcc\t%o5, 1, %o5\n+\tstb\t%o4, [%o0]\n+\tbgu,pt\t%XCC, 7b\n+\t add\t%o0, 1, %o0\t\t/* advance dst */\n+\tadd\t%o1, %o0, %o1\t\t/* restore %o1 */\n+.Lmv_dst_aligned_on_8:\n+\tandcc\t%o1, 7, %o5\n+\tbrnz,pn\t%o5, .Lsrc_dst_unaligned_on_8\n+\t prefetch [%o1 + (1 * BLOCK_SIZE)], 20\n+\n+.Lmv_src_dst_aligned_on_8:\n+/* check if we are copying MED_MAX or more bytes */\n+\tcmp\t%o2, MED_MAX\t\t/* limit to store buffer size */\n+\tbleu,pt\t%XCC, .Lmedlong\n+\t prefetch [%o1 + (2 * BLOCK_SIZE)], 20\n+\n+/* The mv_align loop below mimics the memcpy code for large aligned copies,\n+ * but does not use the ASI_STBI_P (block initializing store) performance\n+ * optimization. This is used when memcpy is incorrectly invoked with\n+ * overlapping buffers. */\n+\n+.Lmv_large_align8_copy:\t\t\t/* Src and dst share 8 byte align */\n+\t\t\t\t\t/* align dst to 64 byte boundary */\n+\tandcc\t%o0, 0x3f, %o3\t\t/* check for dst 64 byte aligned */\n+\tbrz,pn\t%o3, .Lmv_aligned_on_64\n+\t sub\t%o3, 64, %o3\t\t/* %o3 has negative bytes to move */\n+\tadd\t%o2, %o3, %o2\t\t/* adjust remaining count */\n+.Lmv_align_to_64:\n+\tldx\t[%o1], %o4\n+\tadd\t%o1, 8, %o1\t\t/* increment src ptr */\n+\taddcc\t%o3, 8, %o3\n+\tstx\t%o4, [%o0]\n+\tbrnz,pt\t%o3, .Lmv_align_to_64\n+\t add\t%o0, 8, %o0\t\t/* increment dst ptr */\n+\n+.Lmv_aligned_on_64:\n+\tandn\t%o2, 0x3f, %o5\t\t/* %o5 is multiple of block size */\n+\tand\t%o2, 0x3f, %o2\t\t/* residue bytes in %o2 */\n+.Lmv_align_loop:\n+\tldx\t[%o1],%o4\n+\tstx\t%o4,[%o0]\n+\tprefetch [%o0 + (10 * BLOCK_SIZE)], 22\n+\tprefetch [%o1 + (10 * BLOCK_SIZE)], 21\n+\tsubcc\t%o5, 64, %o5\n+\tldx\t[%o1+8],%o4\n+\tstx\t%o4,[%o0+8]\n+\tldx\t[%o1+16],%o4\n+\tstx\t%o4,[%o0+16]\n+\tldx\t[%o1+24],%o4\n+\tstx\t%o4,[%o0+24]\n+\tldx\t[%o1+32],%o4\n+\tstx\t%o4,[%o0+32]\n+\tldx\t[%o1+40],%o4\n+\tstx\t%o4,[%o0+40]\n+\tldx\t[%o1+48],%o4\n+\tadd\t%o1, 64, %o1\n+\tstx\t%o4,[%o0+48]\n+\tadd\t%o0, 64, %o0\n+\tldx\t[%o1-8],%o4\n+\tbgt,pt\t%XCC, .Lmv_align_loop\n+\t stx\t%o4,[%o0-8]\n+\n+\tba\t.Lmedlong\n+\t nop\n+END(__memmove_niagara7)\n+\n+ENTRY(__mempcpy_niagara7)\n+\t/* %o0=dst, %o1=src, %o2=len */\n+\tba,pt\t%icc, 101f\n+\t add\t%o0, %o2, %g1\t\t/* save dst + len */\n+END(__mempcpy_niagara7)\n+\n+\t.align\t32\n+ENTRY(__memcpy_niagara7)\n+100:\t/* %o0=dst, %o1=src, %o2=len */\n+\tmov\t%o0, %g1\t\t/* save %o0 */\n+101:\n+#ifndef __arch64__\n+\tsrl\t%o2, 0, %o2\n+#endif\n+\tcmp\t%o2, SMALL_MAX\t\t/* check for not small case */\n+\tbgeu,pn\t%XCC, .Lmedium\t\t/* go to larger cases */\n+.Lmv_short:\n+\t cmp\t%o2, SHORTCOPY\t\t/* check for really short case */\n+\tble,pn\t%XCC, .Lsmallfin\n+\t or\t%o0, %o1, %o4\t\t/* prepare alignment check */\n+\tandcc\t%o4, 0x3, %o5\t\t/* test for word alignment */\n+\tbnz,pn\t%XCC, .Lsmallunalign\t/* branch to non-word aligned case */\n+\t nop\n+\tsubcc\t%o2, 7, %o2\t\t/* adjust count */\n+\tble,pn\t%XCC, .Lsmallwordx\n+\t andcc\t%o4, 0x7, %o5\t\t/* test for long alignment */\n+/* 8 or more bytes, src and dest start on word boundary\n+ * %o4 contains or %o0, %o1 */\n+.Lsmalllong:\n+\tbnz,pn\t%XCC, .Lsmallwords\t/* branch to word aligned case */\n+\t cmp\t%o2, SHORT_LONG-7\n+\tbge,a\t%XCC, .Lmedl64\t\t/* if we branch */\n+\t sub\t%o2,56,%o2\t\t/* adjust %o2 to -63 off count */\n+\n+/* slightly unroll the small_long_loop to improve very short copies */\n+\tcmp\t%o2, 32-7\n+\tblt,a,pn %XCC, .Lsmall_long_l\n+\t sub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+\tldx\t[%o1], %o5\n+\tldx\t[%o1+8], %o4\n+\tldx\t[%o1+16], %o3\n+\n+\tsubcc\t%o2, 24, %o2\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+\tstx\t%o5, [%o0]\t\t/* write word */\n+\tstx\t%o4, [%o0+8]\t\t/* write word */\n+\tstx\t%o3, [%o0+16]\t\t/* write word */\n+\n+\tadd\t%o0, 24, %o0\n+\n+/* end loop unroll */\n+\n+.Lsmall_long_l:\n+\tldx\t[%o1+%o0], %o3\n+\tsubcc\t%o2, 8, %o2\n+\tadd\t%o0, 8, %o0\n+\tbgu,pn\t%XCC, .Lsmall_long_l\t/* loop until done */\n+\t stx\t%o3, [%o0-8]\t\t/* write word */\n+\taddcc\t%o2, 7, %o2\t\t/* restore %o2 to correct count */\n+\tbnz,pn\t%XCC, .Lsmall_long_x\t/* check for completion */\n+\t add\t%o1, %o0, %o1\t\t/* restore %o1 */\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+.Lsmall_long_x:\n+\tcmp\t%o2, 4\t\t\t/* check for 4 or more bytes left */\n+\tblt,pn\t%XCC, .Lsmallleft3\t/* if not, go to finish up */\n+\t nop\n+\tlduw\t[%o1], %o3\n+\tadd\t%o1, 4, %o1\n+\tsubcc\t%o2, 4, %o2\n+\tstw\t%o3, [%o0]\n+\tbnz,pn\t%XCC, .Lsmallleft3\n+\t add\t%o0, 4, %o0\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 32\n+/* src and dest start on word boundary; 7 or fewer bytes */\n+.Lsmallwordx:\n+\tlduw\t[%o1], %o3\t\t/* read word */\n+\taddcc\t%o2, 3, %o2\t\t/* restore count */\n+\tbz,pt\t%XCC, .Lsmallexit\n+\t stw\t%o3, [%o0]\t\t/* write word */\n+\tdeccc\t%o2\t\t\t/* reduce count for cc test */\n+\tldub\t[%o1+4], %o3\t\t/* load one byte */\n+\tbz,pt\t%XCC, .Lsmallexit\n+\t stb\t%o3, [%o0+4]\t\t/* store one byte */\n+\tldub\t[%o1+5], %o3\t\t/* load second byte */\n+\tdeccc\t%o2\n+\tbz,pt\t%XCC, .Lsmallexit\n+\t stb\t%o3, [%o0+5]\t\t/* store second byte */\n+\tldub\t[%o1+6], %o3\t\t/* load third byte */\n+\tstb\t%o3, [%o0+6]\t\t/* store third byte */\n+.Lsmallexit:\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 32\n+.Lsmallunalign:\n+\tcmp\t%o2, SHORTCHECK\n+\tble,pn\t%XCC, .Lsmallrest\n+\t cmp\t%o2, SMALL_UMAX\n+\tbge,pt\t%XCC, .Lmedium_join\n+\t andcc\t%o1, 0x3, %o5\t\t/* is src word aligned */\n+\tbz,pn\t%XCC, .Laldst\n+\t cmp\t%o5, 2\t\t\t/* is src half-word aligned */\n+\tbe,pt\t%XCC, .Ls2algn\n+\t cmp\t%o5, 3\t\t\t/* src is byte aligned */\n+.Ls1algn:\n+\tldub\t[%o1], %o3\t\t/* move 1 or 3 bytes to align it */\n+\tinc\t1, %o1\n+\tstb\t%o3, [%o0]\t\t/* move a byte to align src */\n+\tinc\t1, %o0\n+\tbne,pt\t%XCC, .Ls2algn\n+\t dec\t%o2\n+\tb\t.Lald\t\t\t/* now go align dest */\n+\t andcc\t%o0, 0x3, %o5\n+\n+.Ls2algn:\n+\tlduh\t[%o1], %o3\t\t/* know src is 2 byte aligned */\n+\tinc\t2, %o1\n+\tsrl\t%o3, 8, %o4\n+\tstb\t%o4, [%o0]\t\t/* have to do bytes, */\n+\tstb\t%o3, [%o0 + 1]\t\t/* do not know dst alignment */\n+\tinc\t2, %o0\n+\tdec\t2, %o2\n+\n+.Laldst:\n+\tandcc\t%o0, 0x3, %o5\t\t/* align the destination address */\n+.Lald:\tbz,pn\t%XCC, .Lw4cp\n+\t cmp\t%o5, 2\n+\tbe,pn\t%XCC, .Lw2cp\n+\t cmp\t%o5, 3\n+.Lw3cp:\tlduw\t[%o1], %o4\n+\tinc\t4, %o1\n+\tsrl\t%o4, 24, %o5\n+\tstb\t%o5, [%o0]\n+\tbne,pt\t%XCC, .Lw1cp\n+\t inc\t%o0\n+\tdec\t1, %o2\n+\tandn\t%o2, 3, %o3\t\t/* %o3 is aligned word count */\n+\tdec\t4, %o3\t\t\t/* avoid reading beyond tail of src */\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+1:\tsll\t%o4, 8, %g5\t\t/* save residual bytes */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 24, %o5\t\t/* merge with residual */\n+\tor\t%o5, %g5, %g5\n+\tst\t%g5, [%o0]\n+\tbnz,pt\t%XCC, 1b\n+\t inc\t4, %o0\n+\tsub\t%o1, 3, %o1\t\t/* used one byte of last word read */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\t inc\t4, %o2\n+\n+.Lw1cp:\tsrl\t%o4, 8, %o5\n+\tsth\t%o5, [%o0]\n+\tinc\t2, %o0\n+\tdec\t3, %o2\n+\tandn\t%o2, 3, %o3\t\t/* %o3 is aligned word count */\n+\tdec\t4, %o3\t\t\t/* avoid reading beyond tail of src */\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+2:\tsll\t%o4, 24, %g5\t\t/* save residual bytes */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 8, %o5\t\t/* merge with residual */\n+\tor\t%o5, %g5, %g5\n+\tst\t%g5, [%o0]\n+\tbnz,pt\t%XCC, 2b\n+\t inc\t4, %o0\n+\tsub\t%o1, 1, %o1\t\t/* used 3 bytes of last word read */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\t inc\t4, %o2\n+\n+.Lw2cp:\tlduw\t[%o1], %o4\n+\tinc\t4, %o1\n+\tsrl\t%o4, 16, %o5\n+\tsth\t%o5, [%o0]\n+\tinc\t2, %o0\n+\tdec\t2, %o2\n+\tandn\t%o2, 3, %o3\t\t/* %o3 is aligned word count */\n+\tdec\t4, %o3\t\t\t/* avoid reading beyond tail of src */\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+3:\tsll\t%o4, 16, %g5\t\t/* save residual bytes */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 16, %o5\t\t/* merge with residual */\n+\tor\t%o5, %g5, %g5\n+\tst\t%g5, [%o0]\n+\tbnz,pt\t%XCC, 3b\n+\t inc\t4, %o0\n+\tsub\t%o1, 2, %o1\t\t/* used two bytes of last word read */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\t inc\t4, %o2\n+\n+.Lw4cp:\tandn\t%o2, 3, %o3\t\t/* %o3 is aligned word count */\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+\n+1:\tlduw\t[%o1+%o0], %o4\t\t/* read from address */\n+\tdeccc\t4, %o3\t\t\t/* decrement count */\n+\tst\t%o4, [%o0]\t\t/* write at destination address */\n+\tbgu,pt\t%XCC, 1b\n+\t inc\t4, %o0\t\t\t/* increment to address */\n+\tand\t%o2, 3, %o2\t\t/* number of leftover bytes, if any */\n+\n+\t/* simple finish up byte copy, works with any alignment */\n+7:\n+\tadd\t%o1, %o0, %o1\t\t/* restore %o1 */\n+.Lsmallrest:\n+\ttst\t%o2\n+\tbz,pt\t%XCC, .Lsmallx\n+\t cmp\t%o2, 4\n+\tblt,pn\t%XCC, .Lsmallleft3\n+\t nop\n+\tsub\t%o2, 3, %o2\n+.Lsmallnotalign4:\n+\tldub\t[%o1], %o3\t\t/* read byte */\n+\tsubcc\t%o2, 4, %o2\t\t/* reduce count by 4 */\n+\tstb\t%o3, [%o0]\t\t/* write byte */\n+\tldub\t[%o1+1], %o3\t\t/* repeat for total of 4 bytes */\n+\tadd\t%o1, 4, %o1\t\t/* advance SRC by 4 */\n+\tstb\t%o3, [%o0+1]\n+\tldub\t[%o1-2], %o3\n+\tadd\t%o0, 4, %o0\t\t/* advance DST by 4 */\n+\tstb\t%o3, [%o0-2]\n+\tldub\t[%o1-1], %o3\n+\tbgu,pt\t%XCC, .Lsmallnotalign4\t/* loop til 3 or fewer bytes remain */\n+\t stb\t%o3, [%o0-1]\n+\taddcc\t%o2, 3, %o2\t\t/* restore count */\n+\tbz,pt\t%XCC, .Lsmallx\n+.Lsmallleft3:\t\t\t\t/* 1, 2, or 3 bytes remain */\n+\t subcc\t%o2, 1, %o2\n+\tldub\t[%o1], %o3\t\t/* load one byte */\n+\tbz,pt\t%XCC, .Lsmallx\n+\t stb\t%o3, [%o0]\t\t/* store one byte */\n+\tldub\t[%o1+1], %o3\t\t/* load second byte */\n+\tsubcc\t%o2, 1, %o2\n+\tbz,pt\t%XCC, .Lsmallx\n+\t stb\t%o3, [%o0+1]\t\t/* store second byte */\n+\tldub\t[%o1+2], %o3\t\t/* load third byte */\n+\tstb\t%o3, [%o0+2]\t\t/* store third byte */\n+.Lsmallx:\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+.Lsmallfin:\n+\ttst\t%o2\n+\tbnz,pn\t%XCC, .Lsmallleft3\n+\t nop\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 16\n+.Lsmallwords:\n+\tlduw\t[%o1], %o3\t\t/* read word */\n+\tsubcc\t%o2, 8, %o2\t\t/* update count */\n+\tstw\t%o3, [%o0]\t\t/* write word */\n+\tadd\t%o1, 8, %o1\t\t/* update SRC */\n+\tlduw\t[%o1-4], %o3\t\t/* read word */\n+\tadd\t%o0, 8, %o0\t\t/* update DST */\n+\tbgu,pt\t%XCC, .Lsmallwords\t/* loop until done */\n+\t stw\t%o3, [%o0-4]\t\t/* write word */\n+\taddcc\t%o2, 7, %o2\t\t/* restore count */\n+\tbz,pt\t%XCC, .Lsmallexit\t/* check for completion */\n+\t cmp\t%o2, 4\t\t\t/* check for 4 or more bytes left */\n+\tblt,pt\t%XCC, .Lsmallleft3\t/* if not, go to finish up */\n+\t nop\n+\tlduw\t[%o1], %o3\n+\tadd\t%o1, 4, %o1\n+\tsubcc\t%o2, 4, %o2\n+\tadd\t%o0, 4, %o0\n+\tbnz,pn\t%XCC, .Lsmallleft3\n+\t stw\t%o3, [%o0-4]\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 16\n+.Lmedium:\n+.Lmedium_join:\n+\tneg\t%o0, %o5\n+\tandcc\t%o5, 7, %o5\t\t/* bytes till DST 8 byte aligned */\n+\tbrz,pt\t%o5, .Ldst_aligned_on_8\n+\n+\t/* %o5 has the bytes to be written in partial store. */\n+\t sub\t%o2, %o5, %o2\n+\tsub\t%o1, %o0, %o1\t\t/* %o1 gets the difference */\n+7:\t\t\t\t\t/* dst aligning loop */\n+\tldub\t[%o1+%o0], %o4\t\t/* load one byte */\n+\tsubcc\t%o5, 1, %o5\n+\tstb\t%o4, [%o0]\n+\tbgu,pt\t%XCC, 7b\n+\t add\t%o0, 1, %o0\t\t/* advance dst */\n+\tadd\t%o1, %o0, %o1\t\t/* restore %o1 */\n+.Ldst_aligned_on_8:\n+\tandcc\t%o1, 7, %o5\n+\tbrnz,pt\t%o5, .Lsrc_dst_unaligned_on_8\n+\t nop\n+\n+.Lsrc_dst_aligned_on_8:\n+\t/* check if we are copying MED_MAX or more bytes */\n+\tcmp\t%o2, MED_MAX\t\t/* limit to store buffer size */\n+\tbgu,pn\t%XCC, .Llarge_align8_copy\n+\t nop\n+/*\n+ * Special case for handling when src and dest are both long word aligned\n+ * and total data to move is less than MED_MAX bytes\n+ */\n+.Lmedlong:\n+\tsubcc\t%o2, 63, %o2\t\t/* adjust length to allow cc test */\n+\tble,pn\t%XCC, .Lmedl63\t\t/* skip big loop if < 64 bytes */\n+\t nop\n+.Lmedl64:\n+\tldx\t[%o1], %o4\t\t/* load */\n+\tsubcc\t%o2, 64, %o2\t\t/* decrement length count */\n+\tstx\t%o4, [%o0]\t\t/* and store */\n+\tldx\t[%o1+8], %o3\t\t/* a block of 64 bytes */\n+\tstx\t%o3, [%o0+8]\n+\tldx\t[%o1+16], %o4\n+\tstx\t%o4, [%o0+16]\n+\tldx\t[%o1+24], %o3\n+\tstx\t%o3, [%o0+24]\n+\tldx\t[%o1+32], %o4\t\t/* load */\n+\tstx\t%o4, [%o0+32]\t\t/* and store */\n+\tldx\t[%o1+40], %o3\t\t/* a block of 64 bytes */\n+\tadd\t%o1, 64, %o1\t\t/* increase src ptr by 64 */\n+\tstx\t%o3, [%o0+40]\n+\tldx\t[%o1-16], %o4\n+\tadd\t%o0, 64, %o0\t\t/* increase dst ptr by 64 */\n+\tstx\t%o4, [%o0-16]\n+\tldx\t[%o1-8], %o3\n+\tbgu,pt\t%XCC, .Lmedl64\t\t/* repeat if at least 64 bytes left */\n+\t stx\t%o3, [%o0-8]\n+.Lmedl63:\n+\taddcc\t%o2, 32, %o2\t\t/* adjust remaining count */\n+\tble,pt\t%XCC, .Lmedl31\t\t/* to skip if 31 or fewer bytes left */\n+\t nop\n+\tldx\t[%o1], %o4\t\t/* load */\n+\tsub\t%o2, 32, %o2\t\t/* decrement length count */\n+\tstx\t%o4, [%o0]\t\t/* and store */\n+\tldx\t[%o1+8], %o3\t\t/* a block of 32 bytes */\n+\tadd\t%o1, 32, %o1\t\t/* increase src ptr by 32 */\n+\tstx\t%o3, [%o0+8]\n+\tldx\t[%o1-16], %o4\n+\tadd\t%o0, 32, %o0\t\t/* increase dst ptr by 32 */\n+\tstx\t%o4, [%o0-16]\n+\tldx\t[%o1-8], %o3\n+\tstx\t%o3, [%o0-8]\n+.Lmedl31:\n+\taddcc\t%o2, 16, %o2\t\t/* adjust remaining count */\n+\tble,pt\t%XCC, .Lmedl15\t\t/* skip if 15 or fewer bytes left */\n+\t nop\n+\tldx\t[%o1], %o4\t\t/* load and store 16 bytes */\n+\tadd\t%o1, 16, %o1\t\t/* increase src ptr by 16 */\n+\tstx\t%o4, [%o0]\n+\tsub\t%o2, 16, %o2\t\t/* decrease count by 16 */\n+\tldx\t[%o1-8], %o3\n+\tadd\t%o0, 16, %o0\t\t/* increase dst ptr by 16 */\n+\tstx\t%o3, [%o0-8]\n+.Lmedl15:\n+\taddcc\t%o2, 15, %o2\t\t/* restore count */\n+\tbz,pt\t%XCC, .Lsmallexit\t/* exit if finished */\n+\t cmp\t%o2, 8\n+\tblt,pt\t%XCC, .Lmedw7\t\t/* skip if 7 or fewer bytes left */\n+\t tst\t%o2\n+\tldx\t[%o1], %o4\t\t/* load 8 bytes */\n+\tadd\t%o1, 8, %o1\t\t/* increase src ptr by 8 */\n+\tadd\t%o0, 8, %o0\t\t/* increase dst ptr by 8 */\n+\tsubcc\t%o2, 8, %o2\t\t/* decrease count by 8 */\n+\tbnz,pn\t%XCC, .Lmedw7\n+\t stx\t%o4, [%o0-8]\t\t/* and store 8 bytes */\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 16\n+.Lsrc_dst_unaligned_on_8:\n+\t/* DST is 8-byte aligned, src is not */\n+\tandcc\t%o1, 0x3, %o5\t\t/* test word alignment */\n+\tbnz,pt\t%XCC, .Lunalignsetup\t/* branch if not word aligned */\n+\t nop\n+\n+/*\n+ * Handle all cases where src and dest are aligned on word\n+ * boundaries. Use unrolled loops for better performance.\n+ * This option wins over standard large data move when\n+ * source and destination is in cache for medium\n+ * to short data moves.\n+ */\n+\tcmp %o2, MED_WMAX\t\t/* limit to store buffer size */\n+\tbge,pt\t%XCC, .Lunalignrejoin\t/* otherwise rejoin main loop */\n+\t nop\n+\n+\tsubcc\t%o2, 31, %o2\t\t/* adjust length to allow cc test */\n+\t\t\t\t\t/* for end of loop */\n+\tble,pt\t%XCC, .Lmedw31\t\t/* skip big loop if less than 16 */\n+.Lmedw32:\n+\t ld\t[%o1], %o4\t\t/* move a block of 32 bytes */\n+\tsllx\t%o4, 32, %o5\n+\tld\t[%o1+4], %o4\n+\tor\t%o4, %o5, %o5\n+\tstx\t%o5, [%o0]\n+\tsubcc\t%o2, 32, %o2\t\t/* decrement length count */\n+\tld\t[%o1+8], %o4\n+\tsllx\t%o4, 32, %o5\n+\tld\t[%o1+12], %o4\n+\tor\t%o4, %o5, %o5\n+\tstx\t%o5, [%o0+8]\n+\tadd\t%o1, 32, %o1\t\t/* increase src ptr by 32 */\n+\tld\t[%o1-16], %o4\n+\tsllx\t%o4, 32, %o5\n+\tld\t[%o1-12], %o4\n+\tor\t%o4, %o5, %o5\n+\tstx\t%o5, [%o0+16]\n+\tadd\t%o0, 32, %o0\t\t/* increase dst ptr by 32 */\n+\tld\t[%o1-8], %o4\n+\tsllx\t%o4, 32, %o5\n+\tld\t[%o1-4], %o4\n+\tor\t%o4, %o5, %o5\n+\tbgu,pt\t%XCC, .Lmedw32\t\t/* repeat if at least 32 bytes left */\n+\t stx\t%o5, [%o0-8]\n+.Lmedw31:\n+\taddcc\t%o2, 31, %o2\t\t/* restore count */\n+\tbz,pt\t%XCC, .Lsmallexit\t/* exit if finished */\n+\t cmp\t%o2, 16\n+\tblt,pt\t%XCC, .Lmedw15\n+\t nop\n+\tld\t[%o1], %o4\t\t/* move a block of 16 bytes */\n+\tsllx\t%o4, 32, %o5\n+\tsubcc\t%o2, 16, %o2\t\t/* decrement length count */\n+\tld\t[%o1+4], %o4\n+\tor\t%o4, %o5, %o5\n+\tstx\t%o5, [%o0]\n+\tadd\t%o1, 16, %o1\t\t/* increase src ptr by 16 */\n+\tld\t[%o1-8], %o4\n+\tadd\t%o0, 16, %o0\t\t/* increase dst ptr by 16 */\n+\tsllx\t%o4, 32, %o5\n+\tld\t[%o1-4], %o4\n+\tor\t%o4, %o5, %o5\n+\tstx\t%o5, [%o0-8]\n+.Lmedw15:\n+\tbz,pt\t%XCC, .Lsmallexit\t/* exit if finished */\n+\t cmp\t%o2, 8\n+\tblt,pn\t%XCC, .Lmedw7\t\t/* skip if 7 or fewer bytes left */\n+\t tst\t%o2\n+\tld\t[%o1], %o4\t\t/* load 4 bytes */\n+\tsubcc\t%o2, 8, %o2\t\t/* decrease count by 8 */\n+\tstw\t%o4, [%o0]\t\t/* and store 4 bytes */\n+\tadd\t%o1, 8, %o1\t\t/* increase src ptr by 8 */\n+\tld\t[%o1-4], %o3\t\t/* load 4 bytes */\n+\tadd\t%o0, 8, %o0\t\t/* increase dst ptr by 8 */\n+\tstw\t%o3, [%o0-4]\t\t/* and store 4 bytes */\n+\tbz,pt\t%XCC, .Lsmallexit\t/* exit if finished */\n+.Lmedw7:\t\t\t\t/* count is ge 1, less than 8 */\n+\t cmp\t%o2, 4\t\t\t/* check for 4 bytes left */\n+\tblt,pn\t%XCC, .Lsmallleft3\t/* skip if 3 or fewer bytes left */\n+\t nop\n+\tld\t[%o1], %o4\t\t/* load 4 bytes */\n+\tadd\t%o1, 4, %o1\t\t/* increase src ptr by 4 */\n+\tadd\t%o0, 4, %o0\t\t/* increase dst ptr by 4 */\n+\tsubcc\t%o2, 4, %o2\t\t/* decrease count by 4 */\n+\tbnz,pt\t%XCC, .Lsmallleft3\n+\t stw\t%o4, [%o0-4]\t\t/* and store 4 bytes */\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 16\n+.Llarge_align8_copy:\t\t\t/* Src and dst 8 byte aligned */\n+\t/* align dst to 64 byte boundary */\n+\tandcc\t%o0, 0x3f, %o3\t\t/* check for dst 64 byte aligned */\n+\tbrz,pn\t%o3, .Laligned_to_64\n+\t andcc\t%o0, 8, %o3\t\t/* odd long words to move? */\n+\tbrz,pt\t%o3, .Laligned_to_16\n+\t nop\n+\tldx\t[%o1], %o4\n+\tsub\t%o2, 8, %o2\n+\tadd\t%o1, 8, %o1\t\t/* increment src ptr */\n+\tadd\t%o0, 8, %o0\t\t/* increment dst ptr */\n+\tstx\t%o4, [%o0-8]\n+.Laligned_to_16:\n+\tandcc\t%o0, 16, %o3\t\t/* pair of long words to move? */\n+\tbrz,pt\t%o3, .Laligned_to_32\n+\t nop\n+\tldx\t[%o1], %o4\n+\tsub\t%o2, 16, %o2\n+\tstx\t%o4, [%o0]\n+\tadd\t%o1, 16, %o1\t\t/* increment src ptr */\n+\tldx\t[%o1-8], %o4\n+\tadd\t%o0, 16, %o0\t\t/* increment dst ptr */\n+\tstx\t%o4, [%o0-8]\n+.Laligned_to_32:\n+\tandcc\t%o0, 32, %o3\t\t/* four long words to move? */\n+\tbrz,pt\t%o3, .Laligned_to_64\n+\t nop\n+\tldx\t[%o1], %o4\n+\tsub\t%o2, 32, %o2\n+\tstx\t%o4, [%o0]\n+\tldx\t[%o1+8], %o4\n+\tstx\t%o4, [%o0+8]\n+\tldx\t[%o1+16], %o4\n+\tstx\t%o4, [%o0+16]\n+\tadd\t%o1, 32, %o1\t\t/* increment src ptr */\n+\tldx\t[%o1-8], %o4\n+\tadd\t%o0, 32, %o0\t\t/* increment dst ptr */\n+\tstx\t%o4, [%o0-8]\n+.Laligned_to_64:\n+/*\tFollowing test is included to avoid issues where existing executables\n+ *\tincorrectly call memcpy with overlapping src and dest instead of memmove\n+ *\n+ *\tif ( (src ge dst) and (dst+len > src)) go to overlap case\n+ *\tif ( (src lt dst) and (src+len > dst)) go to overlap case\n+ */\n+\tcmp\t%o1,%o0\n+\tbge,pt\t%XCC, 1f\n+\t nop\n+/*\t\t\t\tsrc+len > dst? */\n+\tadd\t%o1, %o2, %o4\n+\tcmp\t%o4, %o0\n+\tbgt,pt\t%XCC, .Lmv_aligned_on_64\n+\t nop\n+\tba\t2f\n+\t nop\n+1:\n+/*\t\t\t\tdst+len > src? */\n+\tadd\t%o0, %o2, %o4\n+\tcmp\t%o4, %o1\n+\tbgt,pt\t%XCC, .Lmv_aligned_on_64\n+\t nop\n+2:\n+/*\thandle non-overlapped copies\n+ *\n+ *\tUsing block init store (BIS) instructions to avoid fetching cache\n+ *\tlines from memory. Use ST_CHUNK stores to first element of each cache \n+ *\tline (similar to prefetching) to avoid overfilling STQ or miss buffers.\n+ *\tGives existing cache lines time to be moved out of L1/L2/L3 cache.\n+ */\n+ \tandn\t%o2, 0x3f, %o5\t\t/* %o5 is multiple of block size */\n+ \tand\t%o2, 0x3f, %o2\t\t/* residue bytes in %o2 */\n+ \n+/*\tWe use ASI_STBIMRU_P for the first store to each cache line\n+ *\tfollowed by ASI_STBI_P (mark as LRU) for the last store. That\n+ *\tmixed approach reduces the chances the cache line is removed\n+ *\tbefore we finish setting it, while minimizing the effects on\n+ *\tother cached values during a large memcpy\n+ *\n+ *\tIntermediate stores can be normal since first BIS activates the\n+ *\tcache line in the L2 cache.\n+ *\n+ *\tST_CHUNK batches up initial BIS operations for several cache lines\n+ *\tto allow multiple requests to not be blocked by overflowing the\n+ *\tthe store miss buffer. Then the matching stores for all those\n+ *\tBIS operations are executed.\n+ */\n+\n+.Lalign_loop:\n+\tcmp\t%o5, ST_CHUNK*64\n+\tblu,pt\t%XCC, .Lalign_short\n+\t mov\tST_CHUNK, %o3\n+\tsllx\t%o3, 6, %g5\t\t/* ST_CHUNK*64 */\n+\n+.Lalign_loop_start:\n+\tprefetch [%o1 + (ALIGN_PRE * BLOCK_SIZE)], 21\n+\tsubcc\t%o3, 2, %o3\n+\tldx\t[%o1], %o4\n+\tadd\t%o1, 128, %o1\n+\tEX_ST(STORE_ASI(%o4, %o0))\n+\tadd\t%o0, 64, %o0\n+\tldx\t[%o1-64], %o4\n+\tEX_ST(STORE_ASI(%o4, %o0))\n+\tadd\t%o0, 64, %o0\n+\tbgu,pt\t%XCC, .Lalign_loop_start\n+\t prefetch [%o1 + ((ALIGN_PRE-1) * BLOCK_SIZE)], 21\n+\n+\tmov\tST_CHUNK, %o3\n+\tsub\t%o1, %g5, %o1\t\t/* reset %o1 */\n+\tsub\t%o0, %g5, %o0\t\t/* reset %o0 */\n+\n+\tsub\t%o0, 8, %o0\t\t/* adjust %o0 for ASI alignment */\n+.Lalign_loop_rest:\n+\tldx\t[%o1+8],%o4\n+\tadd\t%o0, 64, %o0\n+\tstx\t%o4, [%o0-48]\n+\tsubcc\t%o3, 1, %o3\n+\tldx\t[%o1+16],%o4\n+\tstx\t%o4, [%o0-40]\n+\tsub\t%o5, 64, %o5\n+\tldx\t[%o1+24],%o4\n+\tstx\t%o4, [%o0-32]\n+\tldx\t[%o1+32],%o4\n+\tstx\t%o4, [%o0-24]\n+\tldx\t[%o1+40],%o4\n+\tstx\t%o4, [%o0-16]\n+\tldx\t[%o1+48],%o4\n+\tstx\t%o4, [%o0-8]\n+\tadd\t%o1, 64, %o1\n+\tldx\t[%o1-8],%o4\n+\tbgu,pt\t%XCC, .Lalign_loop_rest\n+\t EX_ST(STORE_INIT(%o4,%o0))\t/* mark cache line as LRU */\n+\n+\tmov\tST_CHUNK, %o3\n+\tcmp\t%o5, ST_CHUNK*64\n+\tbgu,pt\t%XCC, .Lalign_loop_start\n+\t add\t%o0, 8, %o0\t\t/* restore %o0 from ASI alignment */\n+\n+\tcmp\t%o5, 0\n+\tbeq,pt\t%XCC, .Lalign_done\n+\n+/* no prefetches needed in these loops\n+ * since we are within ALIGN_PRE of the end */\n+.Lalign_short:\n+\t srl\t%o5, 6, %o3\n+.Lalign_loop_short:\n+\tsubcc\t%o3, 1, %o3\n+\tldx\t[%o1], %o4\n+\tadd\t%o1, 64, %o1\n+\tEX_ST(STORE_ASI(%o4, %o0))\n+\tbgu,pt\t%XCC, .Lalign_loop_short\n+\t add\t%o0, 64, %o0\n+\n+\tsub\t%o1, %o5, %o1\t\t/* reset %o1 */\n+\tsub\t%o0, %o5, %o0\t\t/* reset %o0 */\n+\n+\tsub\t%o0, 8, %o0\t\t/* adjust %o0 for ASI alignment */\n+.Lalign_short_rest:\n+\tldx\t[%o1+8],%o4\n+\tadd\t%o0, 64, %o0\n+\tstx\t%o4, [%o0-48]\n+\tldx\t[%o1+16],%o4\n+\tsubcc\t%o5, 64, %o5\n+\tstx\t%o4, [%o0-40]\n+\tldx\t[%o1+24],%o4\n+\tstx\t%o4, [%o0-32]\n+\tldx\t[%o1+32],%o4\n+\tstx\t%o4, [%o0-24]\n+\tldx\t[%o1+40],%o4\n+\tstx\t%o4, [%o0-16]\n+\tldx\t[%o1+48],%o4\n+\tstx\t%o4, [%o0-8]\n+\tadd\t%o1, 64, %o1\n+\tldx\t[%o1-8],%o4\n+\tbgu,pt\t%XCC, .Lalign_short_rest\n+\t EX_ST(STORE_INIT(%o4,%o0))\t/* mark cache line as LRU */\n+\n+\tadd\t%o0, 8, %o0\t\t/* restore %o0 from ASI alignment */\n+\n+.Lalign_done:\n+\tcmp\t%o2, 0\n+\tmembar\t#StoreStore\n+\tbne,pt\t%XCC, .Lmedl63\n+\t subcc\t%o2, 63, %o2\t\t/* adjust length to allow cc test */\n+\tretl\n+\t mov\tEX_RETVAL(%g1), %o0\t/* restore %o0 */\n+\n+\t.align 16\n+\t/* Dst is on 8 byte boundary; src is not; remaining cnt > SMALL_MAX */\n+\t/* Since block load/store and BIS are not in use for unaligned data,\n+\t * no need to align dst on 64 byte cache line boundary */\n+.Lunalignsetup:\n+.Lunalignrejoin:\n+\trd\t%fprs, %g5\t\t/* check for unused fp */\n+\t/* if fprs.fef == 0, set it.\n+\t * Setting it when already set costs more than checking */\n+\tandcc\t%g5, FPRS_FEF, %g5\t/* test FEF, fprs.du = fprs.dl = 0 */\n+\tbz,a\t%XCC, 1f\n+\t wr\t%g0, FPRS_FEF, %fprs\t/* fprs.fef = 1 */\n+1:\n+\tandn\t%o2, 0x3f, %o5\t\t/* %o5 is multiple of block size */\n+\tand\t%o2, 0x3f, %o2\t\t/* residue bytes in %o2 */\n+\tcmp\t%o2, 8\t\t\t/* Insure we do not load beyond */\n+\tbgt,pt\t%XCC, .Lunalign_adjust\t/* end of source buffer */\n+\t andn\t%o1, 0x7, %o4\t\t/* %o4 has 8 byte aligned src addr */\n+\tadd\t%o2, 64, %o2\t\t/* adjust to leave loop */\n+\tsub\t%o5, 64, %o5\t\t/* early if necessary */\n+.Lunalign_adjust:\n+\talignaddr %o1, %g0, %g0\t\t/* generate %gsr */\n+\tadd\t%o1, %o5, %o1\t\t/* advance %o1 to after blocks */\n+\tldd\t[%o4], %f0\n+.Lunalign_loop:\n+\tprefetch [%o0 + (9 * BLOCK_SIZE)], 20\n+\tldd\t[%o4+8], %f2\n+\tfaligndata %f0, %f2, %f16\n+\tldd\t[%o4+16], %f4\n+\tsubcc\t%o5, BLOCK_SIZE, %o5\n+\tstd\t%f16, [%o0]\n+\tfaligndata %f2, %f4, %f18\n+\tldd\t[%o4+24], %f6\n+\tstd\t%f18, [%o0+8]\n+\tfaligndata %f4, %f6, %f20\n+\tldd\t[%o4+32], %f8\n+\tstd\t%f20, [%o0+16]\n+\tfaligndata %f6, %f8, %f22\n+\tldd\t[%o4+40], %f10\n+\tstd\t%f22, [%o0+24]\n+\tfaligndata %f8, %f10, %f24\n+\tldd\t[%o4+48], %f12\n+\tstd\t%f24, [%o0+32]\n+\tfaligndata %f10, %f12, %f26\n+\tldd\t[%o4+56], %f14\n+\tadd\t%o4, BLOCK_SIZE, %o4\n+\tstd\t%f26, [%o0+40]\n+\tfaligndata %f12, %f14, %f28\n+\tldd\t[%o4], %f0\n+\tstd\t%f28, [%o0+48]\n+\tfaligndata %f14, %f0, %f30\n+\tstd\t%f30, [%o0+56]\n+\tadd\t%o0, BLOCK_SIZE, %o0\n+\tbgu,pt\t%XCC, .Lunalign_loop\n+\t prefetch [%o4 + (11 * BLOCK_SIZE)], 20\n+\n+\t/* Handle trailing bytes, 64 to 127\n+\t * Dest long word aligned, Src not long word aligned */\n+\tcmp\t%o2, 15\n+\tbleu,pt\t%XCC, .Lunalign_short\n+\n+\t andn\t%o2, 0x7, %o5\t\t/* %o5 is multiple of 8 */\n+\tand\t%o2, 0x7, %o2\t\t/* residue bytes in %o2 */\n+\tadd\t%o2, 8, %o2\n+\tsub\t%o5, 8, %o5\t\t/* do not load past end of src */\n+\tandn\t%o1, 0x7, %o4\t\t/* %o4 has 8 byte aligned src addr */\n+\tadd\t%o1, %o5, %o1\t\t/* move %o1 to after multiple of 8 */\n+\tldd\t[%o4], %f0\t\t/* fetch partial word */\n+.Lunalign_by8:\n+\tldd\t[%o4+8], %f2\n+\tadd\t%o4, 8, %o4\n+\tfaligndata %f0, %f2, %f16\n+\tsubcc\t%o5, 8, %o5\n+\tstd\t%f16, [%o0]\n+\tfsrc2\t%f2, %f0\n+\tbgu,pt\t%XCC, .Lunalign_by8\n+\t add\t%o0, 8, %o0\n+\n+.Lunalign_short:\t\t\t/* restore fprs state */\n+\tbrnz,pt\t%g5, .Lsmallrest\n+\t nop\n+\tba\t.Lsmallrest\n+\t wr\t%g5, %g0, %fprs\n+END(__memcpy_niagara7)\n+\n+#endif\ndiff --git a/sysdeps/sparc/sparc64/multiarch/memcpy.S b/sysdeps/sparc/sparc64/multiarch/memcpy.S\nindex b6396ee..d72f4b1 100644\n--- a/sysdeps/sparc/sparc64/multiarch/memcpy.S\n+++ b/sysdeps/sparc/sparc64/multiarch/memcpy.S\n@@ -27,7 +27,19 @@ ENTRY(memcpy)\n # ifdef SHARED\n \tSETUP_PIC_REG_LEAF(o3, o5)\n # endif\n-\tset\tHWCAP_SPARC_CRYPTO, %o1\n+\tset\tHWCAP_SPARC_ADP, %o1\n+\tandcc\t%o0, %o1, %g0\n+\tbe\t1f\n+\t nop\n+# ifdef SHARED\n+\tsethi\t%gdop_hix22(__memcpy_niagara7), %o1\n+\txor\t%o1, %gdop_lox10(__memcpy_niagara7), %o1\n+# else\n+\tset\t__memcpy_niagara7, %o1\n+# endif\n+\tba\t10f\n+\t nop\n+1: set\tHWCAP_SPARC_CRYPTO, %o1\n \tandcc\t%o0, %o1, %g0\n \tbe\t1f\n \t andcc\t%o0, HWCAP_SPARC_N2, %g0\n@@ -89,7 +101,19 @@ ENTRY(__mempcpy)\n # ifdef SHARED\n \tSETUP_PIC_REG_LEAF(o3, o5)\n # endif\n-\tset\tHWCAP_SPARC_CRYPTO, %o1\n+\tset HWCAP_SPARC_ADP, %o1\n+\tandcc %o0, %o1, %g0\n+ be 1f\n+\t nop\n+# ifdef SHARED\n+\tsethi\t%gdop_hix22(__mempcpy_niagara7), %o1\n+\txor\t%o1, %gdop_lox10(__mempcpy_niagara7), %o1\n+# else\n+\tset\t__mempcpy_niagara7, %o1\n+# endif\n+\tba 10f\n+\t nop\n+1:\tset\tHWCAP_SPARC_CRYPTO, %o1\n \tandcc\t%o0, %o1, %g0\n \tbe\t1f\n \t andcc\t%o0, HWCAP_SPARC_N2, %g0\ndiff --git a/sysdeps/sparc/sparc64/multiarch/memmove.S b/sysdeps/sparc/sparc64/multiarch/memmove.S\nnew file mode 100644\nindex 0000000..43bdf08\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/multiarch/memmove.S\n@@ -0,0 +1,72 @@\n+/* Multiple versions of memmove and bcopy\n+ All versions must be listed in ifunc-impl-list.c.\n+ Copyright (C) 2017 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, write to the Free\n+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\n+ 02111-1307 USA. */\n+\n+#include <sysdep.h>\n+\n+#if IS_IN (libc)\n+\t.text\n+ENTRY(memmove)\n+\t.type\tmemmove, @gnu_indirect_function\n+# ifdef SHARED\n+\tSETUP_PIC_REG_LEAF(o3, o5)\n+# endif\n+\tset\tHWCAP_SPARC_ADP, %o1\n+\tandcc\t%o0, %o1, %g0\n+\tbe\t1f\n+\t nop\n+# ifdef SHARED\n+\tsethi\t%gdop_hix22(__memmove_niagara7), %o1\n+\txor\t%o1, %gdop_lox10(__memmove_niagara7), %o1\n+# else\n+\tset\t__memmove_niagara7, %o1\n+# endif\n+\tba 10f\n+\t nop\n+1:\n+# ifdef SHARED\n+\tsethi %gdop_hix22(__memmove_ultra1), %o1\n+\txor %o1, %gdop_lox10(__memmove_ultra1), %o1\n+# else\n+\tset __memmove_ultra1, %o1\n+# endif\n+10:\n+# ifdef SHARED\n+\tadd\t%o3, %o1, %o1\n+# endif\n+\tretl\n+\t mov\t%o1, %o0\n+END(memmove)\n+\n+libc_hidden_builtin_def (memmove)\n+\n+#undef libc_hidden_builtin_def\n+#define libc_hidden_builtin_def(name)\n+#undef weak_alias\n+#define weak_alias(x, y)\n+#undef libc_hidden_def\n+#define libc_hidden_def(name)\n+\n+#define memmove __memmove_ultra1\n+#define __memmove __memmove_ultra1\n+\n+#endif\n+\n+#include \"../memmove.S\"\n+\ndiff --git a/sysdeps/sparc/sparc64/multiarch/memset-niagara7.S b/sysdeps/sparc/sparc64/multiarch/memset-niagara7.S\nnew file mode 100644\nindex 0000000..624fbae\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/multiarch/memset-niagara7.S\n@@ -0,0 +1,334 @@\n+/* Set a block of memory to some byte value. For SUN4V M7.\n+ Copyright (C) 2017 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, see\n+ <http://www.gnu.org/licenses/>. */\n+\n+#include <sysdep.h>\n+\n+#ifndef XCC\n+# define XCC xcc\n+#endif\n+\t.register\t%g2, #scratch\n+\t.register\t%g3, #scratch\n+\n+/* The algorithm is as follows :\n+ *\n+ *\tFor small 7 or fewer bytes stores, bytes will be stored.\n+ *\n+ *\tFor less than 32 bytes stores, align the address on 4 byte boundary.\n+ *\tThen store as many 4-byte chunks, followed by trailing bytes.\n+ *\n+ *\tFor sizes greater than 32 bytes, align the address on 8 byte boundary.\n+ *\tif (count >= 64) {\n+ *\t\tstore 8-bytes chunks to align the address on 64 byte boundary\n+ *\t\tif (value to be set is zero && count >= MIN_ZERO) {\n+ *\t\t\tUsing BIS stores, set the first long word of each\n+ *\t\t\t64-byte cache line to zero which will also clear the\n+ *\t\t\tother seven long words of the cache line.\n+ *\t\t}\n+ *\t\telse if (count >= MIN_LOOP) {\n+ *\t\t\tUsing BIS stores, set the first long word of each of\n+ *\t\t\tST_CHUNK cache lines (64 bytes each) before the main\n+ *\t\t\tloop is entered.\n+ *\t\t\tIn the main loop, continue pre-setting the first long\n+ *\t\t\tword of each cache line ST_CHUNK lines in advance while\n+ *\t\t\tsetting the other seven long words (56 bytes) of each\n+ *\t\t\tcache line until fewer than ST_CHUNK*64 bytes remain.\n+ *\t\t\tThen set the remaining seven long words of each cache\n+ *\t\t\tline that has already had its first long word set.\n+ *\t\t}\n+ *\t\tstore remaining data in 64-byte chunks until less than\n+ *\t\t64 bytes remain.\n+ *\t}\n+ *\tStore as many 8-byte chunks, followed by trailing bytes.\n+ *\n+ *\n+ * BIS = Block Init Store\n+ * Doing the advance store of the first element of the cache line\n+ * initiates the displacement of a cache line while only using a single\n+ * instruction in the pipeline. That avoids various pipeline delays,\n+ * such as filling the miss buffer. The performance effect is\n+ * similar to prefetching for normal stores.\n+ * The special case for zero fills runs faster and uses fewer instruction\n+ * cycles than the normal memset loop.\n+ *\n+ * We only use BIS for memset of greater than MIN_LOOP bytes because a sequence\n+ * BIS stores must be followed by a membar #StoreStore. The benefit of\n+ * the BIS store must be balanced against the cost of the membar operation.\n+ */\n+\n+/*\n+ * ASI_STBI_P marks the cache line as \"least recently used\"\n+ * which means if many threads are active, it has a high chance\n+ * of being pushed out of the cache between the first initializing\n+ * store and the final stores.\n+ * Thus, we use ASI_STBIMRU_P which marks the cache line as\n+ * \"most recently used\" for all but the last store to the cache line.\n+ */\n+\n+#define ASI_BLK_INIT_QUAD_LDD_P 0xe2\n+#define ASI_ST_BLK_INIT_MRU_P 0xf2\n+\n+#define ASI_STBI_P\tASI_BLK_INIT_QUAD_LDD_P\n+#define ASI_STBIMRU_P\tASI_ST_BLK_INIT_MRU_P\n+\n+#define ST_CHUNK\t24 /* multiple of 4 due to loop unrolling */\n+#define MIN_LOOP\t(ST_CHUNK)*64\n+#define MIN_ZERO\t256\n+\n+#define EX_ST(x)\tx\n+#define EX_RETVAL(x)\tx\n+#define STORE_ASI(src,addr)\tstxa src, [addr] ASI_STBIMRU_P\n+#define STORE_INIT(src,addr)\tstxa src, [addr] ASI_STBI_P\n+\n+#if IS_IN (libc)\n+\n+\t.text\n+\t.align\t\t32\n+\n+ENTRY(__bzero_niagara7)\n+\t/* bzero (dst, size) */\n+\tmov\t%o1, %o2\n+\tmov\t0, %o1\n+\t/* fall through into memset code */\n+END(__bzero_niagara7)\n+\n+ENTRY(__memset_niagara7)\n+\t/* memset (src, c, size) */\n+\tmov\t%o0, %o5\t\t/* copy sp1 before using it */\n+\tcmp\t%o2, 7\t\t\t/* if small counts, just write bytes */\n+\tbleu,pn %XCC, .Lwrchar\n+\t and\t%o1, 0xff, %o1\t\t/* o1 is (char)c */\n+\n+\tsll\t%o1, 8, %o3\n+\tor\t%o1, %o3, %o1\t\t/* now o1 has 2 bytes of c */\n+\tsll\t%o1, 16, %o3\n+\tcmp\t%o2, 32\n+\tblu,pn\t%XCC, .Lwdalign\n+\t or\t%o1, %o3, %o1\t\t/* now o1 has 4 bytes of c */\n+\n+\tsllx\t%o1, 32, %o3\n+\tor\t%o1, %o3, %o1\t\t/* now o1 has 8 bytes of c */\n+\n+.Ldbalign:\n+\tandcc\t%o5, 7, %o3\t\t/* is sp1 aligned on a 8 byte bound? */\n+\tbz,pt\t%XCC, .Lblkalign\t/* already long word aligned */\n+\t sub\t%o3, 8, %o3\t\t/* -(bytes till long word aligned) */\n+\n+\tadd\t%o2, %o3, %o2\t\t/* update o2 with new count */\n+\t/* Set -(%o3) bytes till sp1 long word aligned */\n+1:\tstb\t%o1, [%o5]\t\t/* there is at least 1 byte to set */\n+\tinccc\t%o3\t\t\t/* byte clearing loop */\n+\tbl,pt\t%XCC, 1b\n+\t inc\t%o5\n+\n+\t/* Now sp1 is long word aligned (sp1 is found in %o5) */\n+.Lblkalign:\n+\tcmp\t%o2, 64\t\t/* check if there are 64 bytes to set */\n+\tblu,pn\t%XCC, .Lwrshort\n+\t mov\t%o2, %o3\n+\n+\tandcc\t%o5, 63, %o3\t\t/* is sp1 block aligned? */\n+\tbz,pt\t%XCC, .Lblkwr\t\t/* now block aligned */\n+\t sub\t%o3, 64, %o3\t\t/* o3 is -(bytes till block aligned) */\n+\tadd\t%o2, %o3, %o2\t\t/* o2 is the remainder */\n+\n+\t/* Store -(%o3) bytes till dst is block (64 byte) aligned. */\n+\t/* Use long word stores. */\n+\t/* Recall that dst is already long word aligned */\n+1:\n+\taddcc\t%o3, 8, %o3\n+\tstx\t%o1, [%o5]\n+\tbl,pt\t%XCC, 1b\n+\t add\t%o5, 8, %o5\n+\n+\t/* Now sp1 is block aligned */\n+.Lblkwr:\n+\tandn\t%o2, 63, %o4\t\t/* calculate size of blocks in bytes */\n+\tbrz,pn\t%o1, .Lwrzero\t\t/* special case if c == 0 */\n+\t and\t%o2, 63, %o3\t\t/* %o3 = bytes left after blk stores */\n+\n+\tcmp\t%o4, MIN_LOOP\t\t/* check for enough bytes to set */\n+\tblu,pn\t%XCC, .Lshort_set\t/* to justify cost of membar */\n+\t nop\t\t\t\t/* must be > pre-cleared lines */\n+\n+\t/* initial cache-clearing stores */\n+\t/* get store pipeline moving */\n+\n+/* Primary memset loop for large memsets */\n+.Lwr_loop:\n+\tmov\tST_CHUNK, %g1\n+.Lwr_loop_start:\n+\tsubcc\t%g1, 4, %g1\n+\tEX_ST(STORE_ASI(%o1,%o5))\n+\tadd\t%o5, 64, %o5\n+\tEX_ST(STORE_ASI(%o1,%o5))\n+\tadd\t%o5, 64, %o5\n+\tEX_ST(STORE_ASI(%o1,%o5))\n+\tadd\t%o5, 64, %o5\n+\tEX_ST(STORE_ASI(%o1,%o5))\n+\tbgu\t%XCC, .Lwr_loop_start\n+\t add\t%o5, 64, %o5\n+\n+\tsub\t%o5, ST_CHUNK*64, %o5\t/* reset %o5 */\n+\tmov\tST_CHUNK, %g1\n+\tsub\t%o5, 8, %o5\t\t/* adjust %o5 for ASI store */\n+\n+.Lwr_loop_rest:\n+\tstx\t%o1,[%o5+8+8]\n+\tsub\t%o4, 64, %o4\n+\tstx\t%o1,[%o5+16+8]\n+\tsubcc\t%g1, 1, %g1\n+\tstx\t%o1,[%o5+24+8]\n+\tstx\t%o1,[%o5+32+8]\n+\tstx\t%o1,[%o5+40+8]\n+\tadd\t%o5, 64, %o5\n+\tstx\t%o1,[%o5-8]\n+\tbgu\t%XCC, .Lwr_loop_rest\n+\t EX_ST(STORE_INIT(%o1,%o5))\n+\n+\t add\t%o5, 8, %o5\t\t/* restore %o5 offset */\n+\n+\t/* If more than ST_CHUNK*64 bytes remain to set, continue */\n+\t/* setting the first long word of each cache line in advance */\n+\t/* to keep the store pipeline moving. */\n+\n+\tcmp\t%o4, ST_CHUNK*64\n+\tbge,pt\t%XCC, .Lwr_loop_start\n+\t mov\tST_CHUNK, %g1\n+\n+\tbrz,a,pn %o4, .Lasi_done\n+\t nop\n+\n+\tsub\t%o5, 8, %o5\t\t/* adjust %o5 for ASI store */\n+.Lwr_loop_small:\n+\tadd\t%o5, 8, %o5\t\t/* adjust %o5 for ASI store */\n+\tEX_ST(STORE_ASI(%o1,%o5))\n+\tstx\t%o1,[%o5+8]\n+\tstx\t%o1,[%o5+16]\n+\tstx\t%o1,[%o5+24]\n+\tstx\t%o1,[%o5+32]\n+\tsubcc\t%o4, 64, %o4\n+\tstx\t%o1,[%o5+40]\n+\tadd\t%o5, 56, %o5\n+\tstx\t%o1,[%o5-8]\n+\tbgu,pt\t%XCC, .Lwr_loop_small\n+\t EX_ST(STORE_INIT(%o1,%o5))\n+\n+\tba\t.Lasi_done\n+\t add\t%o5, 8, %o5\t\t/* restore %o5 offset */\n+\n+/* Special case loop for zero fill memsets */\n+/* For each 64 byte cache line, single STBI to first element */\n+/* clears line */\n+.Lwrzero:\n+\tcmp\t%o4, MIN_ZERO\t\t/* check if enough bytes to set */\n+\t\t\t\t\t/* to pay %asi + membar cost */\n+\tblu\t%XCC, .Lshort_set\n+\t nop\n+\tsub\t%o4, 256, %o4\n+\n+.Lwrzero_loop:\n+\tmov\t64, %g3\n+\tEX_ST(STORE_INIT(%o1,%o5))\n+\tsubcc\t%o4, 256, %o4\n+\tEX_ST(STORE_INIT(%o1,%o5+%g3))\n+\tadd\t%o5, 256, %o5\n+\tsub\t%g3, 192, %g3\n+\tEX_ST(STORE_INIT(%o1,%o5+%g3))\n+\tadd %g3, 64, %g3\n+\tbge,pt\t%XCC, .Lwrzero_loop\n+\t EX_ST(STORE_INIT(%o1,%o5+%g3))\n+\tadd\t%o4, 256, %o4\n+\n+\tbrz,pn\t%o4, .Lbsi_done\n+\t nop\n+.Lwrzero_small:\n+\tEX_ST(STORE_INIT(%o1,%o5))\n+\tsubcc\t%o4, 64, %o4\n+\tbgu,pt\t%XCC, .Lwrzero_small\n+\t add\t%o5, 64, %o5\n+\n+.Lasi_done:\n+.Lbsi_done:\n+\tmembar\t#StoreStore\t\t/* required by use of BSI */\n+\n+.Lshort_set:\n+\tcmp\t%o4, 64\t\t\t/* check if 64 bytes to set */\n+\tblu\t%XCC, 5f\n+\t nop\n+4:\t\t\t\t\t/* set final blocks of 64 bytes */\n+\tstx\t%o1, [%o5]\n+\tstx\t%o1, [%o5+8]\n+\tstx\t%o1, [%o5+16]\n+\tstx\t%o1, [%o5+24]\n+\tsubcc\t%o4, 64, %o4\n+\tstx\t%o1, [%o5+32]\n+\tstx\t%o1, [%o5+40]\n+\tadd\t%o5, 64, %o5\n+\tstx\t%o1, [%o5-16]\n+\tbgu,pt\t%XCC, 4b\n+\t stx\t%o1, [%o5-8]\n+\n+5:\n+\t/* Set the remaining long words */\n+.Lwrshort:\n+\tsubcc\t%o3, 8, %o3\t\t/* Can we store any long words? */\n+\tblu,pn\t%XCC, .Lwrchars\n+\t and\t%o2, 7, %o2\t\t/* calc bytes left after long words */\n+6:\n+\tsubcc\t%o3, 8, %o3\n+\tstx\t%o1, [%o5]\t\t/* store the long words */\n+\tbgeu,pt %XCC, 6b\n+\t add\t%o5, 8, %o5\n+\n+.Lwrchars:\t\t\t\t/* check for extra chars */\n+\tbrnz\t%o2, .Lwrfin\n+\t nop\n+\tretl\n+\t nop\n+\n+.Lwdalign:\n+\tandcc\t%o5, 3, %o3\t\t/* is sp1 aligned on a word boundary */\n+\tbz,pn\t%XCC, .Lwrword\n+\t andn\t%o2, 3, %o3\t\t/* create word sized count in %o3 */\n+\n+\tdec\t%o2\t\t\t/* decrement count */\n+\tstb\t%o1, [%o5]\t\t/* clear a byte */\n+\tb\t.Lwdalign\n+\t inc\t%o5\t\t\t/* next byte */\n+\n+.Lwrword:\n+\tsubcc\t%o3, 4, %o3\n+\tst\t%o1, [%o5]\t\t/* 4-byte writing loop */\n+\tbnz,pt\t%XCC, .Lwrword\n+\t add\t%o5, 4, %o5\n+\tand\t%o2, 3, %o2\t\t/* leftover count, if any */\n+\n+.Lwrchar:\n+\t/* Set the remaining bytes, if any */\n+\tbrz\t%o2, .Lexit\n+\t nop\n+.Lwrfin:\n+\tdeccc\t%o2\n+\tstb\t%o1, [%o5]\n+\tbgu,pt\t%XCC, .Lwrfin\n+\t inc\t%o5\n+.Lexit:\n+\tretl\t\t\t\t/* %o0 was preserved */\n+\t nop\n+END(__memset_niagara7)\n+#endif\ndiff --git a/sysdeps/sparc/sparc64/multiarch/memset.S b/sysdeps/sparc/sparc64/multiarch/memset.S\nindex 9469d5e..d066272 100644\n--- a/sysdeps/sparc/sparc64/multiarch/memset.S\n+++ b/sysdeps/sparc/sparc64/multiarch/memset.S\n@@ -27,7 +27,19 @@ ENTRY(memset)\n # ifdef SHARED\n \tSETUP_PIC_REG_LEAF(o3, o5)\n # endif\n-\tset\tHWCAP_SPARC_CRYPTO, %o1\n+\tset\tHWCAP_SPARC_ADP, %o1\n+\tandcc\t%o0, %o1, %g0\n+\tbe\t1f\n+\t nop\n+# ifdef SHARED\n+\tsethi\t%gdop_hix22(__memset_niagara7), %o1\n+\txor\t%o1, %gdop_lox10(__memset_niagara7), %o1\n+# else\n+\tset\t__memset_niagara7, %o1\n+# endif\n+\tba\t10f\n+\t nop\n+1:\tset\tHWCAP_SPARC_CRYPTO, %o1\n \tandcc\t%o0, %o1, %g0\n \tbe\t1f\n \t andcc\t%o0, HWCAP_SPARC_BLKINIT, %g0\n@@ -69,7 +81,19 @@ ENTRY(__bzero)\n # ifdef SHARED\n \tSETUP_PIC_REG_LEAF(o3, o5)\n # endif\n-\tset\tHWCAP_SPARC_CRYPTO, %o1\n+\tset\tHWCAP_SPARC_ADP, %o1\n+\tandcc\t%o0, %o1, %g0\n+\tbe\t1f\n+\t nop\n+# ifdef SHARED\n+\tsethi\t%gdop_hix22(__bzero_niagara7), %o1\n+\txor\t%o1, %gdop_lox10(__bzero_niagara7), %o1\n+# else\n+\tset\t__bzero_niagara7, %o1\n+# endif\n+\tba\t10f\n+\t nop\n+1:\tset\tHWCAP_SPARC_CRYPTO, %o1\n \tandcc\t%o0, %o1, %g0\n \tbe\t1f\n \t andcc\t%o0, HWCAP_SPARC_BLKINIT, %g0\ndiff --git a/sysdeps/sparc/sparc64/multiarch/rtld-memmove.c b/sysdeps/sparc/sparc64/multiarch/rtld-memmove.c\nnew file mode 100644\nindex 0000000..66fe118\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/multiarch/rtld-memmove.c\n@@ -0,0 +1 @@\n+#include <../rtld-memmove.c>\n", "prefixes": [ "3/3" ] }