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