bca718
From 43b14a5489db870aeeda0766bde25e29747f6864 Mon Sep 17 00:00:00 2001
bca718
From: Stefan Liebler <stli@linux.vnet.ibm.com>
bca718
Date: Thu, 8 Oct 2015 11:13:14 +0200
bca718
Subject: [PATCH 16/30] S390: Optimize strcat and wcscat.
bca718
bca718
upstream-commit-id: d626a24f235dbd4c446b241211a9a264a1eedb9e
bca718
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00155.html
bca718
bca718
This patch provides optimized versions of strcat and wcscat with the z13
bca718
vector instructions.
bca718
bca718
ChangeLog:
bca718
bca718
	* sysdeps/s390/multiarch/strcat-c.c: New File.
bca718
	* sysdeps/s390/multiarch/strcat-vx.S: Likewise.
bca718
	* sysdeps/s390/multiarch/strcat.c: Likewise.
bca718
	* sysdeps/s390/multiarch/wcscat-c.c: Likewise.
bca718
	* sysdeps/s390/multiarch/wcscat-vx.S: Likewise.
bca718
	* sysdeps/s390/multiarch/wcscat.c: Likewise.
bca718
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strcat and
bca718
	wcscat functions.
bca718
	* sysdeps/s390/multiarch/ifunc-impl-list.c
bca718
	(__libc_ifunc_impl_list): Add ifunc test for strcat, wcscat.
bca718
	* string/strcat.c (STRCAT): Define and use macro.
bca718
	* wcsmbs/wcscat.c: Use WCSCAT if defined.
bca718
	* string/test-strcat.c: Add wcscat support.
bca718
	* wcsmbs/test-wcscat.c: New File.
bca718
	* wcsmbs/Makefile (strop-tests): Add wcscat.
bca718
	* benchtests/bench-strcat.c: Add wcscat support.
bca718
	* benchtests/bench-wcscat.c: New File.
bca718
	* benchtests/Makefile (wcsmbs-bench): Add wcscat.
bca718
---
bca718
 benchtests/Makefile                      |   2 +-
bca718
 benchtests/bench-strcat.c                |  90 ++++++++++------
bca718
 benchtests/bench-wcscat.c                |  20 ++++
bca718
 string/strcat.c                          |   8 +-
bca718
 string/test-strcat.c                     | 124 ++++++++++++++--------
bca718
 sysdeps/s390/multiarch/Makefile          |   6 +-
bca718
 sysdeps/s390/multiarch/ifunc-impl-list.c |   3 +
bca718
 sysdeps/s390/multiarch/strcat-c.c        |  28 +++++
bca718
 sysdeps/s390/multiarch/strcat-vx.S       | 161 ++++++++++++++++++++++++++++
bca718
 sysdeps/s390/multiarch/strcat.c          |  27 +++++
bca718
 sysdeps/s390/multiarch/wcscat-c.c        |  25 +++++
bca718
 sysdeps/s390/multiarch/wcscat-vx.S       | 175 +++++++++++++++++++++++++++++++
bca718
 sysdeps/s390/multiarch/wcscat.c          |  28 +++++
bca718
 wcsmbs/Makefile                          |   2 +-
bca718
 wcsmbs/test-wcscat-ifunc.c               |  20 ++++
bca718
 wcsmbs/test-wcscat.c                     |  20 ++++
bca718
 wcsmbs/wcscat.c                          |   5 +
bca718
 17 files changed, 660 insertions(+), 84 deletions(-)
bca718
 create mode 100644 benchtests/bench-wcscat.c
bca718
 create mode 100644 sysdeps/s390/multiarch/strcat-c.c
bca718
 create mode 100644 sysdeps/s390/multiarch/strcat-vx.S
bca718
 create mode 100644 sysdeps/s390/multiarch/strcat.c
bca718
 create mode 100644 sysdeps/s390/multiarch/wcscat-c.c
bca718
 create mode 100644 sysdeps/s390/multiarch/wcscat-vx.S
bca718
 create mode 100644 sysdeps/s390/multiarch/wcscat.c
bca718
 create mode 100644 wcsmbs/test-wcscat-ifunc.c
bca718
 create mode 100644 wcsmbs/test-wcscat.c
bca718
bca718
diff --git a/benchtests/Makefile b/benchtests/Makefile
bca718
index dfab95f..91db23c 100644
bca718
--- a/benchtests/Makefile
bca718
+++ b/benchtests/Makefile
bca718
@@ -38,7 +38,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
bca718
 		strcat strchr strchrnul strcmp strcpy strcspn strlen \
bca718
 		strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
bca718
 		strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
bca718
-wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy
bca718
+wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat
bca718
 string-bench-all := $(string-bench) ${wcsmbs-bench}
bca718
 
bca718
 stdlib-bench := strtod
bca718
diff --git a/benchtests/bench-strcat.c b/benchtests/bench-strcat.c
bca718
index 6602009..1abf6d3 100644
bca718
--- a/benchtests/bench-strcat.c
bca718
+++ b/benchtests/bench-strcat.c
bca718
@@ -1,5 +1,5 @@
bca718
 /* Measure strcat functions.
bca718
-   Copyright (C) 2013 Free Software Foundation, Inc.
bca718
+   Copyright (C) 2013-2015 Free Software Foundation, Inc.
bca718
    This file is part of the GNU C Library.
bca718
 
bca718
    The GNU C Library is free software; you can redistribute it and/or
bca718
@@ -17,19 +17,45 @@
bca718
    <http://www.gnu.org/licenses/>.  */
bca718
 
bca718
 #define TEST_MAIN
bca718
-#define TEST_NAME "strcat"
bca718
+#ifndef WIDE
bca718
+# define TEST_NAME "strcat"
bca718
+#else
bca718
+# define TEST_NAME "wcscat"
bca718
+#endif /* WIDE */
bca718
 #include "bench-string.h"
bca718
 
bca718
-typedef char *(*proto_t) (char *, const char *);
bca718
-char *simple_strcat (char *, const char *);
bca718
-
bca718
-IMPL (simple_strcat, 0)
bca718
-IMPL (strcat, 1)
bca718
-
bca718
-char *
bca718
-simple_strcat (char *dst, const char *src)
bca718
+#ifndef WIDE
bca718
+# define STRCAT strcat
bca718
+# define CHAR char
bca718
+# define sfmt "s"
bca718
+# define SIMPLE_STRCAT simple_strcat
bca718
+# define STRLEN strlen
bca718
+# define STRCMP strcmp
bca718
+# define BIG_CHAR CHAR_MAX
bca718
+# define SMALL_CHAR 127
bca718
+#else
bca718
+# include <wchar.h>
bca718
+# define STRCAT wcscat
bca718
+# define CHAR wchar_t
bca718
+# define sfmt "ls"
bca718
+# define SIMPLE_STRCAT simple_wcscat
bca718
+# define STRLEN wcslen
bca718
+# define STRCMP wcscmp
bca718
+# define BIG_CHAR WCHAR_MAX
bca718
+# define SMALL_CHAR 1273
bca718
+#endif /* WIDE */
bca718
+
bca718
+
bca718
+typedef CHAR *(*proto_t) (CHAR *, const CHAR *);
bca718
+CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *);
bca718
+
bca718
+IMPL (SIMPLE_STRCAT, 0)
bca718
+IMPL (STRCAT, 1)
bca718
+
bca718
+CHAR *
bca718
+SIMPLE_STRCAT (CHAR *dst, const CHAR *src)
bca718
 {
bca718
-  char *ret = dst;
bca718
+  CHAR *ret = dst;
bca718
   while (*dst++ != '\0');
bca718
   --dst;
bca718
   while ((*dst++ = *src++) != '\0');
bca718
@@ -37,9 +63,9 @@ simple_strcat (char *dst, const char *src)
bca718
 }
bca718
 
bca718
 static void
bca718
-do_one_test (impl_t *impl, char *dst, const char *src)
bca718
+do_one_test (impl_t *impl, CHAR *dst, const CHAR *src)
bca718
 {
bca718
-  size_t k = strlen (dst), i, iters = INNER_LOOP_ITERS;
bca718
+  size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS;
bca718
   timing_t start, stop, cur;
bca718
 
bca718
   if (CALL (impl, dst, src) != dst)
bca718
@@ -50,9 +76,9 @@ do_one_test (impl_t *impl, char *dst, const char *src)
bca718
       return;
bca718
     }
bca718
 
bca718
-  if (strcmp (dst + k, src) != 0)
bca718
+  if (STRCMP (dst + k, src) != 0)
bca718
     {
bca718
-      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
bca718
+      error (0, 0, "Wrong result in function %s dst \"%" sfmt "\" src \"%" sfmt "\"",
bca718
 	     impl->name, dst, src);
bca718
       ret = 1;
bca718
       return;
bca718
@@ -75,18 +101,18 @@ static void
bca718
 do_test (size_t align1, size_t align2, size_t len1, size_t len2, int max_char)
bca718
 {
bca718
   size_t i;
bca718
-  char *s1, *s2;
bca718
+  CHAR *s1, *s2;
bca718
 
bca718
   align1 &= 7;
bca718
-  if (align1 + len1 >= page_size)
bca718
+  if ((align1 + len1) * sizeof (CHAR) >= page_size)
bca718
     return;
bca718
 
bca718
   align2 &= 7;
bca718
-  if (align2 + len1 + len2 >= page_size)
bca718
+  if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size)
bca718
     return;
bca718
 
bca718
-  s1 = (char *) (buf1 + align1);
bca718
-  s2 = (char *) (buf2 + align2);
bca718
+  s1 = (CHAR *) (buf1) + align1;
bca718
+  s2 = (CHAR *) (buf2) + align2;
bca718
 
bca718
   for (i = 0; i < len1; ++i)
bca718
     s1[i] = 32 + 23 * i % (max_char - 32);
bca718
@@ -120,26 +146,26 @@ test_main (void)
bca718
 
bca718
   for (i = 0; i < 16; ++i)
bca718
     {
bca718
-      do_test (0, 0, i, i, 127);
bca718
-      do_test (0, 0, i, i, 255);
bca718
-      do_test (0, i, i, i, 127);
bca718
-      do_test (i, 0, i, i, 255);
bca718
+      do_test (0, 0, i, i, SMALL_CHAR);
bca718
+      do_test (0, 0, i, i, BIG_CHAR);
bca718
+      do_test (0, i, i, i, SMALL_CHAR);
bca718
+      do_test (i, 0, i, i, BIG_CHAR);
bca718
     }
bca718
 
bca718
   for (i = 1; i < 8; ++i)
bca718
     {
bca718
-      do_test (0, 0, 8 << i, 8 << i, 127);
bca718
-      do_test (8 - i, 2 * i, 8 << i, 8 << i, 127);
bca718
-      do_test (0, 0, 8 << i, 2 << i, 127);
bca718
-      do_test (8 - i, 2 * i, 8 << i, 2 << i, 127);
bca718
+      do_test (0, 0, 8 << i, 8 << i, SMALL_CHAR);
bca718
+      do_test (8 - i, 2 * i, 8 << i, 8 << i, SMALL_CHAR);
bca718
+      do_test (0, 0, 8 << i, 2 << i, SMALL_CHAR);
bca718
+      do_test (8 - i, 2 * i, 8 << i, 2 << i, SMALL_CHAR);
bca718
     }
bca718
 
bca718
   for (i = 1; i < 8; ++i)
bca718
     {
bca718
-      do_test (i, 2 * i, 8 << i, 1, 127);
bca718
-      do_test (2 * i, i, 8 << i, 1, 255);
bca718
-      do_test (i, i, 8 << i, 10, 127);
bca718
-      do_test (i, i, 8 << i, 10, 255);
bca718
+      do_test (i, 2 * i, 8 << i, 1, SMALL_CHAR);
bca718
+      do_test (2 * i, i, 8 << i, 1, BIG_CHAR);
bca718
+      do_test (i, i, 8 << i, 10, SMALL_CHAR);
bca718
+      do_test (i, i, 8 << i, 10, BIG_CHAR);
bca718
     }
bca718
 
bca718
   return ret;
bca718
diff --git a/benchtests/bench-wcscat.c b/benchtests/bench-wcscat.c
bca718
new file mode 100644
bca718
index 0000000..cd0dbc0
bca718
--- /dev/null
bca718
+++ b/benchtests/bench-wcscat.c
bca718
@@ -0,0 +1,20 @@
bca718
+/* Measure wcscat functions.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#define WIDE 1
bca718
+#include "bench-strcat.c"
bca718
diff --git a/string/strcat.c b/string/strcat.c
bca718
index f9e4bc6..017bb41 100644
bca718
--- a/string/strcat.c
bca718
+++ b/string/strcat.c
bca718
@@ -20,11 +20,13 @@
bca718
 
bca718
 #undef strcat
bca718
 
bca718
+#ifndef STRCAT
bca718
+# define STRCAT strcat
bca718
+#endif
bca718
+
bca718
 /* Append SRC on the end of DEST.  */
bca718
 char *
bca718
-strcat (dest, src)
bca718
-     char *dest;
bca718
-     const char *src;
bca718
+STRCAT (char *dest, const char *src)
bca718
 {
bca718
   char *s1 = dest;
bca718
   const char *s2 = src;
bca718
diff --git a/string/test-strcat.c b/string/test-strcat.c
bca718
index 2dc189a..a822733 100644
bca718
--- a/string/test-strcat.c
bca718
+++ b/string/test-strcat.c
bca718
@@ -18,19 +18,52 @@
bca718
    <http://www.gnu.org/licenses/>.  */
bca718
 
bca718
 #define TEST_MAIN
bca718
-#define TEST_NAME "strcat"
bca718
+#ifndef WIDE
bca718
+# define TEST_NAME "strcat"
bca718
+#else
bca718
+# define TEST_NAME "wcscat"
bca718
+#endif /* WIDE */
bca718
 #include "test-string.h"
bca718
 
bca718
-typedef char *(*proto_t) (char *, const char *);
bca718
-char *simple_strcat (char *, const char *);
bca718
+#ifndef WIDE
bca718
+# define STRCAT strcat
bca718
+# define CHAR char
bca718
+# define UCHAR unsigned char
bca718
+# define sfmt "s"
bca718
+# define SIMPLE_STRCAT simple_strcat
bca718
+# define STRLEN strlen
bca718
+# define STRCMP strcmp
bca718
+# define MEMSET memset
bca718
+# define MEMCPY memcpy
bca718
+# define MEMCMP memcmp
bca718
+# define BIG_CHAR CHAR_MAX
bca718
+# define SMALL_CHAR 127
bca718
+#else
bca718
+# include <wchar.h>
bca718
+# define STRCAT wcscat
bca718
+# define CHAR wchar_t
bca718
+# define UCHAR wchar_t
bca718
+# define sfmt "ls"
bca718
+# define SIMPLE_STRCAT simple_wcscat
bca718
+# define STRLEN wcslen
bca718
+# define STRCMP wcscmp
bca718
+# define MEMSET wmemset
bca718
+# define MEMCPY wmemcpy
bca718
+# define MEMCMP wmemcmp
bca718
+# define BIG_CHAR WCHAR_MAX
bca718
+# define SMALL_CHAR 1273
bca718
+#endif /* WIDE */
bca718
 
bca718
-IMPL (simple_strcat, 0)
bca718
-IMPL (strcat, 1)
bca718
+typedef CHAR *(*proto_t) (CHAR *, const CHAR *);
bca718
+CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *);
bca718
 
bca718
-char *
bca718
-simple_strcat (char *dst, const char *src)
bca718
+IMPL (SIMPLE_STRCAT, 0)
bca718
+IMPL (STRCAT, 1)
bca718
+
bca718
+CHAR *
bca718
+SIMPLE_STRCAT (CHAR *dst, const CHAR *src)
bca718
 {
bca718
-  char *ret = dst;
bca718
+  CHAR *ret = dst;
bca718
   while (*dst++ != '\0');
bca718
   --dst;
bca718
   while ((*dst++ = *src++) != '\0');
bca718
@@ -38,9 +71,9 @@ simple_strcat (char *dst, const char *src)
bca718
 }
bca718
 
bca718
 static void
bca718
-do_one_test (impl_t *impl, char *dst, const char *src)
bca718
+do_one_test (impl_t *impl, CHAR *dst, const char *src)
bca718
 {
bca718
-  size_t k = strlen (dst);
bca718
+  size_t k = STRLEN (dst);
bca718
   if (CALL (impl, dst, src) != dst)
bca718
     {
bca718
       error (0, 0, "Wrong result in function %s %p %p", impl->name,
bca718
@@ -49,9 +82,9 @@ do_one_test (impl_t *impl, char *dst, const char *src)
bca718
       return;
bca718
     }
bca718
 
bca718
-  if (strcmp (dst + k, src) != 0)
bca718
+  if (STRCMP (dst + k, src) != 0)
bca718
     {
bca718
-      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
bca718
+      error (0, 0, "Wrong result in function %s dst \"%" sfmt "\" src \"%" sfmt "\"",
bca718
 	     impl->name, dst, src);
bca718
       ret = 1;
bca718
       return;
bca718
@@ -62,18 +95,18 @@ static void
bca718
 do_test (size_t align1, size_t align2, size_t len1, size_t len2, int max_char)
bca718
 {
bca718
   size_t i;
bca718
-  char *s1, *s2;
bca718
+  CHAR *s1, *s2;
bca718
 
bca718
   align1 &= 7;
bca718
-  if (align1 + len1 >= page_size)
bca718
+  if ((align1 + len1) * sizeof (CHAR) >= page_size)
bca718
     return;
bca718
 
bca718
   align2 &= 7;
bca718
-  if (align2 + len1 + len2 >= page_size)
bca718
+  if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size)
bca718
     return;
bca718
 
bca718
-  s1 = (char *) (buf1 + align1);
bca718
-  s2 = (char *) (buf2 + align2);
bca718
+  s1 = (CHAR *) (buf1) + align1;
bca718
+  s2 = (CHAR *) (buf2) + align2;
bca718
 
bca718
   for (i = 0; i < len1; ++i)
bca718
     s1[i] = 32 + 23 * i % (max_char - 32);
bca718
@@ -93,9 +126,10 @@ static void
bca718
 do_random_tests (void)
bca718
 {
bca718
   size_t i, j, n, align1, align2, len1, len2;
bca718
-  unsigned char *p1 = buf1 + page_size - 512;
bca718
-  unsigned char *p2 = buf2 + page_size - 512;
bca718
-  unsigned char *res;
bca718
+  UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512;
bca718
+  UCHAR *p2 = (UCHAR *) (buf2 + page_size) - 512;
bca718
+  UCHAR *p3 = (UCHAR *) buf1;
bca718
+  UCHAR *res;
bca718
 
bca718
   for (n = 0; n < ITERATIONS; n++)
bca718
     {
bca718
@@ -132,26 +166,26 @@ do_random_tests (void)
bca718
 	    p1[i] = 0;
bca718
 	  else
bca718
 	    {
bca718
-	      p1[i] = random () & 255;
bca718
+	      p1[i] = random () & BIG_CHAR;
bca718
 	      if (i >= align1 && i < len1 + align1 && !p1[i])
bca718
-		p1[i] = (random () & 127) + 3;
bca718
+		p1[i] = (random () & SMALL_CHAR) + 3;
bca718
 	    }
bca718
 	}
bca718
       for (i = 0; i < len2; i++)
bca718
 	{
bca718
-	  buf1[i] = random () & 255;
bca718
-	  if (!buf1[i])
bca718
-	    buf1[i] = (random () & 127) + 3;
bca718
+	  p3[i] = random () & BIG_CHAR;
bca718
+	  if (!p3[i])
bca718
+	    p3[i] = (random () & SMALL_CHAR) + 3;
bca718
 	}
bca718
-      buf1[len2] = 0;
bca718
+      p3[len2] = 0;
bca718
 
bca718
       FOR_EACH_IMPL (impl, 1)
bca718
 	{
bca718
-	  memset (p2 - 64, '\1', align2 + 64);
bca718
-	  memset (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1);
bca718
-	  memcpy (p2 + align2, buf1, len2 + 1);
bca718
-	  res = (unsigned char *) CALL (impl, (char *) (p2 + align2),
bca718
-					(char *) (p1 + align1));
bca718
+	  MEMSET (p2 - 64, '\1', align2 + 64);
bca718
+	  MEMSET (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1);
bca718
+	  MEMCPY (p2 + align2, p3, len2 + 1);
bca718
+	  res = (UCHAR *) CALL (impl, (CHAR *) (p2 + align2),
bca718
+				(CHAR *) (p1 + align1));
bca718
 	  if (res != p2 + align2)
bca718
 	    {
bca718
 	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd %zd) %p != %p",
bca718
@@ -169,7 +203,7 @@ do_random_tests (void)
bca718
 		  break;
bca718
 		}
bca718
 	    }
bca718
-	  if (memcmp (p2 + align2, buf1, len2))
bca718
+	  if (MEMCMP (p2 + align2, p3, len2))
bca718
 	    {
bca718
 	      error (0, 0, "Iteration %zd - garbage in string before, %s (%zd, %zd, %zd, %zd)",
bca718
 		     n, impl->name, align1, align2, len1, len2);
bca718
@@ -185,7 +219,7 @@ do_random_tests (void)
bca718
 		  break;
bca718
 		}
bca718
 	    }
bca718
-	  if (memcmp (p1 + align1, p2 + align2 + len2, len1 + 1))
bca718
+	  if (MEMCMP (p1 + align1, p2 + align2 + len2, len1 + 1))
bca718
 	    {
bca718
 	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd, %zd)",
bca718
 		     n, impl->name, align1, align2, len1, len2);
bca718
@@ -209,26 +243,26 @@ test_main (void)
bca718
 
bca718
   for (i = 0; i < 16; ++i)
bca718
     {
bca718
-      do_test (0, 0, i, i, 127);
bca718
-      do_test (0, 0, i, i, 255);
bca718
-      do_test (0, i, i, i, 127);
bca718
-      do_test (i, 0, i, i, 255);
bca718
+      do_test (0, 0, i, i, SMALL_CHAR);
bca718
+      do_test (0, 0, i, i, BIG_CHAR);
bca718
+      do_test (0, i, i, i, SMALL_CHAR);
bca718
+      do_test (i, 0, i, i, BIG_CHAR);
bca718
     }
bca718
 
bca718
   for (i = 1; i < 8; ++i)
bca718
     {
bca718
-      do_test (0, 0, 8 << i, 8 << i, 127);
bca718
-      do_test (8 - i, 2 * i, 8 << i, 8 << i, 127);
bca718
-      do_test (0, 0, 8 << i, 2 << i, 127);
bca718
-      do_test (8 - i, 2 * i, 8 << i, 2 << i, 127);
bca718
+      do_test (0, 0, 8 << i, 8 << i, SMALL_CHAR);
bca718
+      do_test (8 - i, 2 * i, 8 << i, 8 << i, SMALL_CHAR);
bca718
+      do_test (0, 0, 8 << i, 2 << i, SMALL_CHAR);
bca718
+      do_test (8 - i, 2 * i, 8 << i, 2 << i, SMALL_CHAR);
bca718
     }
bca718
 
bca718
   for (i = 1; i < 8; ++i)
bca718
     {
bca718
-      do_test (i, 2 * i, 8 << i, 1, 127);
bca718
-      do_test (2 * i, i, 8 << i, 1, 255);
bca718
-      do_test (i, i, 8 << i, 10, 127);
bca718
-      do_test (i, i, 8 << i, 10, 255);
bca718
+      do_test (i, 2 * i, 8 << i, 1, SMALL_CHAR);
bca718
+      do_test (2 * i, i, 8 << i, 1, BIG_CHAR);
bca718
+      do_test (i, i, 8 << i, 10, SMALL_CHAR);
bca718
+      do_test (i, i, 8 << i, 10, BIG_CHAR);
bca718
     }
bca718
 
bca718
   do_random_tests ();
bca718
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
bca718
index 98b588f..6283999 100644
bca718
--- a/sysdeps/s390/multiarch/Makefile
bca718
+++ b/sysdeps/s390/multiarch/Makefile
bca718
@@ -4,7 +4,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
bca718
 		   strcpy strcpy-vx \
bca718
 		   stpcpy stpcpy-vx stpcpy-c \
bca718
 		   strncpy strncpy-vx \
bca718
-		   stpncpy stpncpy-vx stpncpy-c
bca718
+		   stpncpy stpncpy-vx stpncpy-c \
bca718
+		   strcat strcat-vx strcat-c
bca718
 endif
bca718
 
bca718
 ifeq ($(subdir),wcsmbs)
bca718
@@ -13,5 +14,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
bca718
 		   wcscpy wcscpy-vx wcscpy-c \
bca718
 		   wcpcpy wcpcpy-vx wcpcpy-c \
bca718
 		   wcsncpy wcsncpy-vx wcsncpy-c \
bca718
-		   wcpncpy wcpncpy-vx wcpncpy-c
bca718
+		   wcpncpy wcpncpy-vx wcpncpy-c \
bca718
+		   wcscat wcscat-vx wcscat-c
bca718
 endif
bca718
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
bca718
index ca69983..ccf4dea 100644
bca718
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
bca718
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
bca718
@@ -97,6 +97,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
bca718
   IFUNC_VX_IMPL (stpncpy);
bca718
   IFUNC_VX_IMPL (wcpncpy);
bca718
 
bca718
+  IFUNC_VX_IMPL (strcat);
bca718
+  IFUNC_VX_IMPL (wcscat);
bca718
+
bca718
 #endif /* HAVE_S390_VX_ASM_SUPPORT */
bca718
 
bca718
   return i;
bca718
diff --git a/sysdeps/s390/multiarch/strcat-c.c b/sysdeps/s390/multiarch/strcat-c.c
bca718
new file mode 100644
bca718
index 0000000..da4fad8
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/strcat-c.c
bca718
@@ -0,0 +1,28 @@
bca718
+/* Default strcat implementation for S/390.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+# define STRCAT  __strcat_c
bca718
+# ifdef SHARED
bca718
+#  undef libc_hidden_builtin_def
bca718
+#  define libc_hidden_builtin_def(name)				\
bca718
+     __hidden_ver1 (__strcat_c, __GI_strcat, __strcat_c);
bca718
+# endif /* SHARED */
bca718
+
bca718
+# include <string/strcat.c>
bca718
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
bca718
diff --git a/sysdeps/s390/multiarch/strcat-vx.S b/sysdeps/s390/multiarch/strcat-vx.S
bca718
new file mode 100644
bca718
index 0000000..3915097
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/strcat-vx.S
bca718
@@ -0,0 +1,161 @@
bca718
+/* Vector optimized 32/64 bit S/390 version of strcat.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+
bca718
+# include "sysdep.h"
bca718
+# include "asm-syntax.h"
bca718
+
bca718
+	.text
bca718
+
bca718
+/* char * strcat (const char *dest, const char *src)
bca718
+   Concatenate two strings.
bca718
+
bca718
+   Register usage:
bca718
+   -r0=saved dest pointer for return
bca718
+   -r1=tmp
bca718
+   -r2=dest
bca718
+   -r3=src
bca718
+   -r4=tmp
bca718
+   -r5=current_len
bca718
+   -v16=part of src
bca718
+   -v17=index of zero
bca718
+   -v18=part of src
bca718
+*/
bca718
+ENTRY(__strcat_vx)
bca718
+	.machine "z13"
bca718
+	.machinemode "zarch_nohighgprs"
bca718
+
bca718
+	lgr	%r0,%r2		/* Save destination pointer for return.  */
bca718
+
bca718
+	/* STRLEN
bca718
+	   r1 = loaded bytes (tmp)
bca718
+	   r4 = zero byte index (tmp)
bca718
+	   r2 = dst
bca718
+	*/
bca718
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
bca718
+	lcbb	%r1,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
bca718
+
bca718
+	vfenezb	%v16,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	vlgvb	%r5,%v16,7	/* Load zero index or 16 if not found.  */
bca718
+	clrjl	%r5,%r1,.Llen_end /* Found zero within loaded bytes, end.  */
bca718
+
bca718
+	/* Align s to 16 byte.  */
bca718
+	risbgn	%r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
bca718
+	lghi	%r5,16		/* current_len = 16.  */
bca718
+	slr	%r5,%r1		/* Compute bytes to 16bytes boundary.  */
bca718
+
bca718
+	/* Find zero in 16byte aligned loop.  */
bca718
+.Llen_loop:
bca718
+	vl	%v16,0(%r5,%r2)	/* Load s.  */
bca718
+	vfenezbs %v16,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	je	.Llen_found	/* Jump away if zero was found.  */
bca718
+	vl	%v16,16(%r5,%r2)
bca718
+	vfenezbs %v16,%v16,%v16
bca718
+	je	.Llen_found16
bca718
+	vl	%v16,32(%r5,%r2)
bca718
+	vfenezbs %v16,%v16,%v16
bca718
+	je	.Llen_found32
bca718
+	vl	%v16,48(%r5,%r2)
bca718
+	vfenezbs %v16,%v16,%v16
bca718
+	je	.Llen_found48
bca718
+
bca718
+	aghi	%r5,64
bca718
+	j	.Llen_loop	/* No zero -> loop.  */
bca718
+
bca718
+.Llen_found48:
bca718
+	aghi	%r5,16
bca718
+.Llen_found32:
bca718
+	aghi	%r5,16
bca718
+.Llen_found16:
bca718
+	aghi	%r5,16
bca718
+.Llen_found:
bca718
+	vlgvb	%r4,%v16,7	/* Load byte index of zero.  */
bca718
+	algr	%r5,%r4
bca718
+
bca718
+.Llen_end:
bca718
+	/* STRCPY
bca718
+	   %r1 = loaded bytes (tmp)
bca718
+	   %r4 = zero byte index (tmp)
bca718
+	   %r3 = curr src pointer
bca718
+	   %r2 = curr dst pointer
bca718
+	 */
bca718
+	la	%r2,0(%r5,%r2)	/* strcpy at end of dst-string.   */
bca718
+
bca718
+	vlbb	%v16,0(%r3),6	/* Load s until next 4k-byte boundary.  */
bca718
+	lcbb	%r1,0(%r3),6	/* Get bytes to 4k-byte boundary or 16.  */
bca718
+
bca718
+	vfenezb	%v17,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	vlgvb	%r5,%v17,7	/* Load zero index or 16 if not found.  */
bca718
+	clrjl	%r5,%r1,.Lcpy_found_align /* If found zero within loaded bytes,
bca718
+					     copy bytes before and return.  */
bca718
+
bca718
+	/* Align s to 16 byte.  */
bca718
+	risbgn	%r4,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
bca718
+	lghi	%r5,15		/* current_len = 15.  */
bca718
+	slr	%r5,%r4		/* Compute highest index to 16byte boundary.  */
bca718
+
bca718
+	vstl	%v16,%r5,0(%r2)	/* Copy loaded characters - no zero.  */
bca718
+	ahi	%r5,1		/* Start loop at next character.  */
bca718
+
bca718
+	/* Find zero in 16byte aligned loop.  */
bca718
+.Lcpy_loop:
bca718
+	vl	%v16,0(%r5,%r3)	/* Load s.  */
bca718
+	vfenezbs %v17,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	je	.Lcpy_found_v16_0 /* Jump away if zero was found.  */
bca718
+	vl	%v18,16(%r5,%r3)/* Load next part of s.  */
bca718
+	vst	%v16,0(%r5,%r2)	/* Store previous part without zero to dst.  */
bca718
+	vfenezbs %v17,%v18,%v18
bca718
+	je	.Lcpy_found_v18_16
bca718
+	vl	%v16,32(%r5,%r3)
bca718
+	vst	%v18,16(%r5,%r2)
bca718
+	vfenezbs %v17,%v16,%v16
bca718
+	je	.Lcpy_found_v16_32
bca718
+	vl	%v18,48(%r5,%r3)
bca718
+	vst	%v16,32(%r5,%r2)
bca718
+	vfenezbs %v17,%v18,%v18
bca718
+	je	.Lcpy_found_v18_48
bca718
+	vst	%v18,48(%r5,%r2)
bca718
+
bca718
+	aghi	%r5,64
bca718
+	j	.Lcpy_loop	/* No zero -> loop.  */
bca718
+
bca718
+.Lcpy_found_v16_32:
bca718
+	aghi	%r5,32
bca718
+.Lcpy_found_v16_0:
bca718
+	la	%r4,0(%r5,%r2)
bca718
+	vlgvb	%r1,%v17,7	/* Load byte index of zero.  */
bca718
+	vstl	%v16,%r1,0(%r4)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+
bca718
+.Lcpy_found_v18_48:
bca718
+	aghi	%r5,32
bca718
+.Lcpy_found_v18_16:
bca718
+	la	%r4,16(%r5,%r2)
bca718
+	vlgvb	%r1,%v17,7	/* Load byte index of zero.  */
bca718
+	vstl	%v18,%r1,0(%r4)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+
bca718
+.Lcpy_found_align:
bca718
+	vstl	%v16,%r5,0(%r2)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+END(__strcat_vx)
bca718
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
bca718
diff --git a/sysdeps/s390/multiarch/strcat.c b/sysdeps/s390/multiarch/strcat.c
bca718
new file mode 100644
bca718
index 0000000..8b5c47e
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/strcat.c
bca718
@@ -0,0 +1,27 @@
bca718
+/* Multiple versions of strcat.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+# include <string.h>
bca718
+# include <ifunc-resolve.h>
bca718
+
bca718
+s390_vx_libc_ifunc2 (__strcat, strcat)
bca718
+
bca718
+#else
bca718
+# include <string/strcat.c>
bca718
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
bca718
diff --git a/sysdeps/s390/multiarch/wcscat-c.c b/sysdeps/s390/multiarch/wcscat-c.c
bca718
new file mode 100644
bca718
index 0000000..49fb64b
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/wcscat-c.c
bca718
@@ -0,0 +1,25 @@
bca718
+/* Default wcscat implementation for S/390.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+# define WCSCAT  __wcscat_c
bca718
+
bca718
+# include <wchar.h>
bca718
+extern __typeof (__wcscat) __wcscat_c;
bca718
+# include <wcsmbs/wcscat.c>
bca718
+#endif
bca718
diff --git a/sysdeps/s390/multiarch/wcscat-vx.S b/sysdeps/s390/multiarch/wcscat-vx.S
bca718
new file mode 100644
bca718
index 0000000..7ee185f
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/wcscat-vx.S
bca718
@@ -0,0 +1,175 @@
bca718
+/* Vector optimized 32/64 bit S/390 version of wcscat.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+
bca718
+# include "sysdep.h"
bca718
+# include "asm-syntax.h"
bca718
+
bca718
+	.text
bca718
+
bca718
+/* wchar_t * wcscat (wchar_t *dest, const wchar_t *src)
bca718
+   Concatenate two strings.
bca718
+
bca718
+   Register usage:
bca718
+   -r0=saved dest pointer for return
bca718
+   -r1=tmp
bca718
+   -r2=dest
bca718
+   -r3=src
bca718
+   -r4=tmp
bca718
+   -r5=current_len
bca718
+   -v16=part of src
bca718
+   -v17=index of zero
bca718
+   -v18=part of src
bca718
+*/
bca718
+ENTRY(__wcscat_vx)
bca718
+	.machine "z13"
bca718
+	.machinemode "zarch_nohighgprs"
bca718
+
bca718
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
bca718
+	lcbb	%r1,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
bca718
+
bca718
+	/* __wcslen_c can handle non 4byte aligned pointers,
bca718
+	   but __wcscpy_c not. Thus if either src or dest is
bca718
+	   not 4byte aligned, use __wcscat_c.  */
bca718
+	tmll	%r2,3		/* Test if s is 4-byte aligned?   */
bca718
+	jne	.Lfallback	/* And use common-code variant if not.  */
bca718
+	tmll	%r3,3		/* Test if src is 4-byte aligned?   */
bca718
+	jne	.Lfallback	/* And use common-code variant if not.  */
bca718
+
bca718
+	lgr	%r0,%r2		/* Save destination pointer for return.  */
bca718
+
bca718
+	/* WCSLEN
bca718
+	   r1 = loaded bytes (tmp)
bca718
+	   r4 = zero byte index (tmp)
bca718
+	   r2 = dst
bca718
+	*/
bca718
+
bca718
+	vfenezf	%v16,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	vlgvb	%r5,%v16,7	/* Load zero index or 16 if not found.  */
bca718
+	clrjl	%r5,%r1,.Llen_end /* Found zero within loaded bytes, end.  */
bca718
+
bca718
+	/* Align s to 16 byte.  */
bca718
+	risbgn	%r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
bca718
+	lghi	%r5,16		/* current_len = 16.  */
bca718
+	slr	%r5,%r1		/* Compute bytes to 16bytes boundary.  */
bca718
+
bca718
+	/* Find zero in 16byte aligned loop.  */
bca718
+.Llen_loop:
bca718
+	vl	%v16,0(%r5,%r2)	/* Load s.  */
bca718
+	vfenezfs %v16,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	je	.Llen_found	/* Jump away if zero was found.  */
bca718
+	vl	%v16,16(%r5,%r2)
bca718
+	vfenezfs %v16,%v16,%v16
bca718
+	je	.Llen_found16
bca718
+	vl	%v16,32(%r5,%r2)
bca718
+	vfenezfs %v16,%v16,%v16
bca718
+	je	.Llen_found32
bca718
+	vl	%v16,48(%r5,%r2)
bca718
+	vfenezfs %v16,%v16,%v16
bca718
+	je	.Llen_found48
bca718
+
bca718
+	aghi	%r5,64
bca718
+	j	.Llen_loop	/* No zero -> loop.  */
bca718
+
bca718
+.Llen_found48:
bca718
+	aghi	%r5,16
bca718
+.Llen_found32:
bca718
+	aghi	%r5,16
bca718
+.Llen_found16:
bca718
+	aghi	%r5,16
bca718
+.Llen_found:
bca718
+	vlgvb	%r4,%v16,7	/* Load byte index of zero.  */
bca718
+	algr	%r5,%r4
bca718
+
bca718
+.Llen_end:
bca718
+	/* WCSCPY
bca718
+	   %r1 = loaded bytes (tmp)
bca718
+	   %r4 = zero byte index (tmp)
bca718
+	   %r3 = curr src pointer
bca718
+	   %r2 = curr dst pointer
bca718
+	 */
bca718
+	la	%r2,0(%r5,%r2)	/* strcpy at end of dst-string.   */
bca718
+
bca718
+	vlbb	%v16,0(%r3),6	/* Load s until next 4k-byte boundary.  */
bca718
+	lcbb	%r1,0(%r3),6	/* Get bytes to 4k-byte boundary or 16.  */
bca718
+
bca718
+	vfenezf	%v17,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	vlgvb	%r5,%v17,7	/* Load zero index or 16 if not found.  */
bca718
+	clrjl	%r5,%r1,.Lcpy_found_align /* If found zero within loaded bytes,
bca718
+					     copy bytes before and return.  */
bca718
+
bca718
+	/* Align s to 16 byte.  */
bca718
+	risbgn	%r4,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
bca718
+	lghi	%r5,15		/* current_len = 15.  */
bca718
+	slr	%r5,%r4		/* Compute highest index to 16byte boundary.  */
bca718
+
bca718
+	vstl	%v16,%r5,0(%r2)	/* Copy loaded characters - no zero.  */
bca718
+	ahi	%r5,1		/* Start loop at next character.  */
bca718
+
bca718
+	/* Find zero in 16byte aligned loop.  */
bca718
+.Lcpy_loop:
bca718
+	vl	%v16,0(%r5,%r3)	/* Load s.  */
bca718
+	vfenezfs %v17,%v16,%v16	/* Find element not equal with zero search.  */
bca718
+	je	.Lcpy_found_v16_0 /* Jump away if zero was found.  */
bca718
+	vl	%v18,16(%r5,%r3) /* Load next part of s.  */
bca718
+	vst	%v16,0(%r5,%r2)	/* Save previous part without zero to dst.  */
bca718
+	vfenezfs %v17,%v18,%v18
bca718
+	je	.Lcpy_found_v18_16
bca718
+	vl	%v16,32(%r5,%r3)
bca718
+	vst	%v18,16(%r5,%r2)
bca718
+	vfenezfs %v17,%v16,%v16
bca718
+	je	.Lcpy_found_v16_32
bca718
+	vl	%v18,48(%r5,%r3)
bca718
+	vst	%v16,32(%r5,%r2)
bca718
+	vfenezfs %v17,%v18,%v18
bca718
+	je	.Lcpy_found_v18_48
bca718
+	vst	%v18,48(%r5,%r2)
bca718
+
bca718
+	aghi	%r5,64
bca718
+	j	.Lcpy_loop	/* No zero -> loop.  */
bca718
+
bca718
+.Lcpy_found_v16_32:
bca718
+	aghi	%r5,32
bca718
+.Lcpy_found_v16_0:
bca718
+	la	%r4,0(%r5,%r2)
bca718
+	vlgvb	%r1,%v17,7	/* Load byte index of zero.  */
bca718
+	aghi	%r1,3		/* Also copy remaining bytes of zero.  */
bca718
+	vstl	%v16,%r1,0(%r4)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+
bca718
+.Lcpy_found_v18_48:
bca718
+	aghi	%r5,32
bca718
+.Lcpy_found_v18_16:
bca718
+	la	%r4,16(%r5,%r2)
bca718
+	vlgvb	%r1,%v17,7	/* Load byte index of zero.  */
bca718
+	aghi	%r1,3		/* Also copy remaining bytes of zero.  */
bca718
+	vstl	%v18,%r1,0(%r4)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+
bca718
+.Lcpy_found_align:
bca718
+	aghi	%r5,3		/* Also copy remaining bytes of found zero.  */
bca718
+	vstl	%v16,%r5,0(%r2)	/* Copy characters including zero.  */
bca718
+	lgr	%r2,%r0		/* Load saved dest-ptr.  */
bca718
+	br	%r14
bca718
+.Lfallback:
bca718
+	jg	__wcscat_c
bca718
+END(__wcscat_vx)
bca718
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
bca718
diff --git a/sysdeps/s390/multiarch/wcscat.c b/sysdeps/s390/multiarch/wcscat.c
bca718
new file mode 100644
bca718
index 0000000..c6fdaa7
bca718
--- /dev/null
bca718
+++ b/sysdeps/s390/multiarch/wcscat.c
bca718
@@ -0,0 +1,28 @@
bca718
+/* Multiple versions of wcscat.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
bca718
+# include <wchar.h>
bca718
+# include <ifunc-resolve.h>
bca718
+
bca718
+s390_vx_libc_ifunc (__wcscat)
bca718
+weak_alias (__wcscat, wcscat)
bca718
+
bca718
+#else
bca718
+# include <wcsmbs/wcscat.c>
bca718
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
bca718
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
bca718
index 89b5b3b..9bfc78c 100644
bca718
--- a/wcsmbs/Makefile
bca718
+++ b/wcsmbs/Makefile
bca718
@@ -42,7 +42,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
bca718
 	    mbrtoc16 c16rtomb
bca718
 
bca718
 strop-tests :=  wcscmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
bca718
-		wcpcpy wcsncpy wcpncpy
bca718
+		wcpcpy wcsncpy wcpncpy wcscat
bca718
 tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
bca718
 	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
bca718
 	 tst-c16c32-1 wcsatcliff $(addprefix test-,$(strop-tests))
bca718
diff --git a/wcsmbs/test-wcscat-ifunc.c b/wcsmbs/test-wcscat-ifunc.c
bca718
new file mode 100644
bca718
index 0000000..53305c6
bca718
--- /dev/null
bca718
+++ b/wcsmbs/test-wcscat-ifunc.c
bca718
@@ -0,0 +1,20 @@
bca718
+/* Test and measure IFUNC implementations of wcscat function.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#define TEST_IFUNC 1
bca718
+#include "test-wcscat.c"
bca718
diff --git a/wcsmbs/test-wcscat.c b/wcsmbs/test-wcscat.c
bca718
new file mode 100644
bca718
index 0000000..9bab33b
bca718
--- /dev/null
bca718
+++ b/wcsmbs/test-wcscat.c
bca718
@@ -0,0 +1,20 @@
bca718
+/* Test wcscat functions.
bca718
+   Copyright (C) 2015 Free Software Foundation, Inc.
bca718
+   This file is part of the GNU C Library.
bca718
+
bca718
+   The GNU C Library is free software; you can redistribute it and/or
bca718
+   modify it under the terms of the GNU Lesser General Public
bca718
+   License as published by the Free Software Foundation; either
bca718
+   version 2.1 of the License, or (at your option) any later version.
bca718
+
bca718
+   The GNU C Library is distributed in the hope that it will be useful,
bca718
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bca718
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bca718
+   Lesser General Public License for more details.
bca718
+
bca718
+   You should have received a copy of the GNU Lesser General Public
bca718
+   License along with the GNU C Library; if not, see
bca718
+   <http://www.gnu.org/licenses/>.  */
bca718
+
bca718
+#define WIDE 1
bca718
+#include "../string/test-strcat.c"
bca718
diff --git a/wcsmbs/wcscat.c b/wcsmbs/wcscat.c
bca718
index 0d34d76..4eb2d93 100644
bca718
--- a/wcsmbs/wcscat.c
bca718
+++ b/wcsmbs/wcscat.c
bca718
@@ -18,6 +18,9 @@
bca718
 
bca718
 #include <wchar.h>
bca718
 
bca718
+#ifdef WCSCAT
bca718
+# define __wcscat WCSCAT
bca718
+#endif
bca718
 
bca718
 /* Append SRC on the end of DEST.  */
bca718
 wchar_t *
bca718
@@ -47,4 +50,6 @@ __wcscat (dest, src)
bca718
 
bca718
   return dest;
bca718
 }
bca718
+#ifndef WCSCAT
bca718
 weak_alias (__wcscat, wcscat)
bca718
+#endif
bca718
-- 
bca718
2.3.0
bca718