ce426f
From 0b3ff29b298c488ab995d4224da2cc36fb56ddce Mon Sep 17 00:00:00 2001
ce426f
From: Stefan Liebler <stli@linux.vnet.ibm.com>
ce426f
Date: Thu, 8 Oct 2015 11:25:00 +0200
ce426f
Subject: [PATCH 20/30] S390: Optimize strchr and wcschr.
ce426f
ce426f
upstream-commit-id: cf150d45a97c6bb8410d6d3acf6e1560e8fe96cc
ce426f
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00094.html
ce426f
ce426f
This patch provides optimized versions of strchr and wcschr with the z13
ce426f
vector instructions.
ce426f
ce426f
ChangeLog:
ce426f
ce426f
	* sysdeps/s390/multiarch/strchr-c.c: New File.
ce426f
	* sysdeps/s390/multiarch/strchr-vx.S: Likewise.
ce426f
	* sysdeps/s390/multiarch/strchr.c: Likewise.
ce426f
	* sysdeps/s390/multiarch/wcschr-c.c: Likewise.
ce426f
	* sysdeps/s390/multiarch/wcschr-vx.S: Likewise.
ce426f
	* sysdeps/s390/multiarch/wcschr.c: Likewise.
ce426f
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strchr and
ce426f
	wcschr functions.
ce426f
	* sysdeps/s390/multiarch/ifunc-impl-list.c
ce426f
	(__libc_ifunc_impl_list): Add ifunc test for strchr, wcschr.
ce426f
	* string/strchr.c (STRCHR): Define and use macro.
ce426f
	* benchtests/bench-wcschr.c: New File.
ce426f
	* benchtests/Makefile (wcsmbs-bench): Add wcschr.
ce426f
---
ce426f
 benchtests/Makefile                      |   2 +-
ce426f
 benchtests/bench-wcschr.c                |  20 ++++++
ce426f
 string/strchr.c                          |   8 ++-
ce426f
 sysdeps/s390/multiarch/Makefile          |   6 +-
ce426f
 sysdeps/s390/multiarch/ifunc-impl-list.c |   3 +
ce426f
 sysdeps/s390/multiarch/strchr-c.c        |  29 +++++++++
ce426f
 sysdeps/s390/multiarch/strchr-vx.S       | 100 ++++++++++++++++++++++++++++++
ce426f
 sysdeps/s390/multiarch/strchr.c          |  28 +++++++++
ce426f
 sysdeps/s390/multiarch/wcschr-c.c        |  31 ++++++++++
ce426f
 sysdeps/s390/multiarch/wcschr-vx.S       | 103 +++++++++++++++++++++++++++++++
ce426f
 sysdeps/s390/multiarch/wcschr.c          |  27 ++++++++
ce426f
 11 files changed, 351 insertions(+), 6 deletions(-)
ce426f
 create mode 100644 benchtests/bench-wcschr.c
ce426f
 create mode 100644 sysdeps/s390/multiarch/strchr-c.c
ce426f
 create mode 100644 sysdeps/s390/multiarch/strchr-vx.S
ce426f
 create mode 100644 sysdeps/s390/multiarch/strchr.c
ce426f
 create mode 100644 sysdeps/s390/multiarch/wcschr-c.c
ce426f
 create mode 100644 sysdeps/s390/multiarch/wcschr-vx.S
ce426f
 create mode 100644 sysdeps/s390/multiarch/wcschr.c
ce426f
ce426f
diff --git a/benchtests/Makefile b/benchtests/Makefile
ce426f
index f6342da..bcb0288 100644
ce426f
--- a/benchtests/Makefile
ce426f
+++ b/benchtests/Makefile
ce426f
@@ -39,7 +39,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
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 wcscat wcsncat \
ce426f
-		wcsncmp wcsncmp
ce426f
+		wcsncmp wcsncmp wcschr
ce426f
 string-bench-all := $(string-bench) ${wcsmbs-bench}
ce426f
 
ce426f
 stdlib-bench := strtod
ce426f
diff --git a/benchtests/bench-wcschr.c b/benchtests/bench-wcschr.c
ce426f
new file mode 100644
ce426f
index 0000000..4287724
ce426f
--- /dev/null
ce426f
+++ b/benchtests/bench-wcschr.c
ce426f
@@ -0,0 +1,20 @@
ce426f
+/* Measure wcschr 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-strchr.c"
ce426f
diff --git a/string/strchr.c b/string/strchr.c
ce426f
index 9d18b7e..69a9cd9 100644
ce426f
--- a/string/strchr.c
ce426f
+++ b/string/strchr.c
ce426f
@@ -27,11 +27,13 @@
ce426f
 
ce426f
 #undef strchr
ce426f
 
ce426f
+#ifndef STRCHR
ce426f
+# define STRCHR strchr
ce426f
+#endif
ce426f
+
ce426f
 /* Find the first occurrence of C in S.  */
ce426f
 char *
ce426f
-strchr (s, c_in)
ce426f
-     const char *s;
ce426f
-     int c_in;
ce426f
+STRCHR (const char *s, int c_in)
ce426f
 {
ce426f
   const unsigned char *char_ptr;
ce426f
   const unsigned long int *longword_ptr;
ce426f
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
ce426f
index d77bee5..1a3673b 100644
ce426f
--- a/sysdeps/s390/multiarch/Makefile
ce426f
+++ b/sysdeps/s390/multiarch/Makefile
ce426f
@@ -8,7 +8,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
ce426f
 		   strcat strcat-vx strcat-c \
ce426f
 		   strncat strncat-vx strncat-c \
ce426f
 		   strcmp strcmp-vx \
ce426f
-		   strncmp strncmp-vx strncmp-c
ce426f
+		   strncmp strncmp-vx strncmp-c \
ce426f
+		   strchr strchr-vx strchr-c
ce426f
 endif
ce426f
 
ce426f
 ifeq ($(subdir),wcsmbs)
ce426f
@@ -21,5 +22,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
ce426f
 		   wcscat wcscat-vx wcscat-c \
ce426f
 		   wcsncat wcsncat-vx wcsncat-c \
ce426f
 		   wcscmp wcscmp-vx wcscmp-c \
ce426f
-		   wcsncmp wcsncmp-vx wcsncmp-c
ce426f
+		   wcsncmp wcsncmp-vx wcsncmp-c \
ce426f
+		   wcschr wcschr-vx wcschr-c
ce426f
 endif
ce426f
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
ce426f
index 5bfc493..b0782ff 100644
ce426f
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
ce426f
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
ce426f
@@ -109,6 +109,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
ce426f
   IFUNC_VX_IMPL (strncmp);
ce426f
   IFUNC_VX_IMPL (wcsncmp);
ce426f
 
ce426f
+  IFUNC_VX_IMPL (strchr);
ce426f
+  IFUNC_VX_IMPL (wcschr);
ce426f
+
ce426f
 #endif /* HAVE_S390_VX_ASM_SUPPORT */
ce426f
 
ce426f
   return i;
ce426f
diff --git a/sysdeps/s390/multiarch/strchr-c.c b/sysdeps/s390/multiarch/strchr-c.c
ce426f
new file mode 100644
ce426f
index 0000000..4384e6b
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/strchr-c.c
ce426f
@@ -0,0 +1,29 @@
ce426f
+/* Default strchr 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 STRCHR  __strchr_c
ce426f
+# undef weak_alias
ce426f
+# ifdef SHARED
ce426f
+#  undef libc_hidden_builtin_def
ce426f
+#  define libc_hidden_builtin_def(name)				\
ce426f
+     __hidden_ver1 (__strchr_c, __GI_strchr, __strchr_c);
ce426f
+# endif /* SHARED */
ce426f
+
ce426f
+# include <string/strchr.c>
ce426f
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
ce426f
diff --git a/sysdeps/s390/multiarch/strchr-vx.S b/sysdeps/s390/multiarch/strchr-vx.S
ce426f
new file mode 100644
ce426f
index 0000000..26180df
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/strchr-vx.S
ce426f
@@ -0,0 +1,100 @@
ce426f
+/* Vector optimized 32/64 bit S/390 version of strchr.
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 *strchr (const char *s, int c)
ce426f
+   Locate character in string.
ce426f
+
ce426f
+   Register usage:
ce426f
+   -r1=tmp
ce426f
+   -r2=s
ce426f
+   -r3=c
ce426f
+   -r4=tmp
ce426f
+   -r5=current_len
ce426f
+   -v16=part of s
ce426f
+   -v17=index of unequal
ce426f
+   -v18=replicated c
ce426f
+*/
ce426f
+ENTRY(__strchr_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
+	lghi	%r5,0		/* current_len = 0.  */
ce426f
+
ce426f
+	vlvgb	%v18,%r3,0	/* Generate vector which elements are all c.
ce426f
+				   If c > 255, c will be truncated.  */
ce426f
+	vrepb	%v18,%v18,0
ce426f
+
ce426f
+	vfeezbs	%v16,%v16,%v18	/* Find element equal with zero search.  */
ce426f
+	vlgvb	%r4,%v16,7	/* Load byte index of character or zero.  */
ce426f
+	clrjl	%r4,%r1,.Lfound /* Return if c/zero is in loaded bytes.  */
ce426f
+
ce426f
+	/* Align s to 16 byte.  */
ce426f
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
ce426f
+	lghi	%r5,16		/* current_len = 16.  */
ce426f
+	slr	%r5,%r4		/* Compute bytes to 16bytes boundary.  */
ce426f
+
ce426f
+	/* Find c/zero in 16 byte aligned loop */
ce426f
+.Lloop:
ce426f
+	vl	%v16,0(%r5,%r2) /* Load s.  */
ce426f
+	vfeezbs	%v16,%v16,%v18	/* Find element equal with zero search.  */
ce426f
+	jno	.Lfound		/* Found c/zero (cc=0|1|2).  */
ce426f
+	vl	%v16,16(%r5,%r2)
ce426f
+	vfeezbs	%v16,%v16,%v18
ce426f
+	jno	.Lfound16
ce426f
+	vl	%v16,32(%r5,%r2)
ce426f
+	vfeezbs	%v16,%v16,%v18
ce426f
+	jno	.Lfound32
ce426f
+	vl	%v16,48(%r5,%r2)
ce426f
+	vfeezbs	%v16,%v16,%v18
ce426f
+	jno	.Lfound48
ce426f
+
ce426f
+	aghi	%r5,64
ce426f
+	j	.Lloop		/* No character and no zero -> loop.  */
ce426f
+
ce426f
+.Lfound48:
ce426f
+	la	%r5,16(%r5)	/* Use la since aghi would clobber cc.  */
ce426f
+.Lfound32:
ce426f
+	la	%r5,16(%r5)
ce426f
+.Lfound16:
ce426f
+	la	%r5,16(%r5)
ce426f
+.Lfound:
ce426f
+	je	.Lzero		/* Found zero, but no c before that zero.  */
ce426f
+
ce426f
+.Lcharacter:
ce426f
+	vlgvb	%r4,%v16,7	/* Load byte index of character.  */
ce426f
+	algr	%r5,%r4
ce426f
+	la	%r2,0(%r5,%r2)	/* Return pointer to character.  */
ce426f
+	br	%r14
ce426f
+
ce426f
+.Lzero:
ce426f
+	llgcr	%r3,%r3		/* char c_char = (char) c.  */
ce426f
+	clije	%r3,0,.Lcharacter /* Found zero and c is zero.  */
ce426f
+	lghi	%r2,0		/* Return null if character not found.  */
ce426f
+	br	%r14
ce426f
+END(__strchr_vx)
ce426f
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
ce426f
diff --git a/sysdeps/s390/multiarch/strchr.c b/sysdeps/s390/multiarch/strchr.c
ce426f
new file mode 100644
ce426f
index 0000000..e2a310f
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/strchr.c
ce426f
@@ -0,0 +1,28 @@
ce426f
+/* Multiple versions of strchr.
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 (__strchr, strchr)
ce426f
+weak_alias (strchr, index)
ce426f
+
ce426f
+#else
ce426f
+# include <string/strchr.c>
ce426f
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
ce426f
diff --git a/sysdeps/s390/multiarch/wcschr-c.c b/sysdeps/s390/multiarch/wcschr-c.c
ce426f
new file mode 100644
ce426f
index 0000000..ad7415e
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/wcschr-c.c
ce426f
@@ -0,0 +1,31 @@
ce426f
+/* Default wcschr 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 WCSCHR  __wcschr_c
ce426f
+
ce426f
+# include <wchar.h>
ce426f
+extern __typeof (wcschr) __wcschr_c;
ce426f
+# ifdef SHARED
ce426f
+#  undef libc_hidden_def
ce426f
+#  define libc_hidden_def(name)					\
ce426f
+  __hidden_ver1 (__wcschr_c, __GI_wcschr, __wcschr_c);
ce426f
+# endif /* SHARED */
ce426f
+
ce426f
+# include <wcsmbs/wcschr.c>
ce426f
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
ce426f
diff --git a/sysdeps/s390/multiarch/wcschr-vx.S b/sysdeps/s390/multiarch/wcschr-vx.S
ce426f
new file mode 100644
ce426f
index 0000000..c1b3f6b
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/wcschr-vx.S
ce426f
@@ -0,0 +1,103 @@
ce426f
+/* Vector optimized 32/64 bit S/390 version of wcschr.
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 *wcschr (const wchar_t *s, wchar_t c)
ce426f
+   Locate character in string.
ce426f
+
ce426f
+   Register usage:
ce426f
+   -r1=tmp
ce426f
+   -r2=s
ce426f
+   -r3=c
ce426f
+   -r4=tmp
ce426f
+   -r5=current_len
ce426f
+   -v16=part of s
ce426f
+   -v17=index of unequal
ce426f
+   -v18=replicated c
ce426f
+*/
ce426f
+ENTRY(__wcschr_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
+	tmll	%r2,3		/* Test if s is 4-byte aligned?   */
ce426f
+	jne	.Lfallback	/* And use common-code variant if not.  */
ce426f
+
ce426f
+	lghi	%r5,0		/* current_len = 0.  */
ce426f
+
ce426f
+	vlvgf	%v18,%r3,0	/* Generate vector which elements are all c.  */
ce426f
+	vrepf	%v18,%v18,0
ce426f
+
ce426f
+	vfeezfs	%v16,%v16,%v18	/* Find element equal with zero search.  */
ce426f
+	vlgvb	%r4,%v16,7	/* Load byte index of character or zero.  */
ce426f
+	clrjl	%r4,%r1,.Lfound /* Return if c/zero is in loaded bytes.  */
ce426f
+
ce426f
+	/* Align s to 16 byte.  */
ce426f
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
ce426f
+	lghi	%r5,16		/* current_len = 16.  */
ce426f
+	slr	%r5,%r4		/* Compute bytes to 16bytes boundary.  */
ce426f
+
ce426f
+	/* Find c/zero in 16byte aligned loop */
ce426f
+.Lloop:
ce426f
+	vl	%v16,0(%r5,%r2) /* Load s.  */
ce426f
+	vfeezfs	%v16,%v16,%v18	/* Find element equal with zero search.  */
ce426f
+	jno	.Lfound		/* Found c/zero (cc=0|1|2).  */
ce426f
+	vl	%v16,16(%r5,%r2)
ce426f
+	vfeezfs	%v16,%v16,%v18
ce426f
+	jno	.Lfound16
ce426f
+	vl	%v16,32(%r5,%r2)
ce426f
+	vfeezfs	%v16,%v16,%v18
ce426f
+	jno	.Lfound32
ce426f
+	vl	%v16,48(%r5,%r2)
ce426f
+	vfeezfs	%v16,%v16,%v18
ce426f
+	jno	.Lfound48
ce426f
+
ce426f
+	aghi	%r5,64
ce426f
+	j	.Lloop		/* No character and no zero -> loop.  */
ce426f
+
ce426f
+.Lfound48:
ce426f
+	la	%r5,16(%r5)	/* Use la since aghi would clobber cc.  */
ce426f
+.Lfound32:
ce426f
+	la	%r5,16(%r5)
ce426f
+.Lfound16:
ce426f
+	la	%r5,16(%r5)
ce426f
+.Lfound:
ce426f
+	je	.Lzero		/* Found zero, but no c before that zero.  */
ce426f
+
ce426f
+.Lcharacter:
ce426f
+	vlgvb	%r4,%v16,7	/* Load byte index of character.  */
ce426f
+	algr	%r5,%r4
ce426f
+	la	%r2,0(%r5,%r2)	/* Return pointer to character.  */
ce426f
+	br	%r14
ce426f
+
ce426f
+.Lzero:
ce426f
+	clije	%r3,0,.Lcharacter /* Found zero and c is zero.  */
ce426f
+	lghi	%r2,0		/* Return null if character not found.  */
ce426f
+	br	%r14
ce426f
+.Lfallback:
ce426f
+	jg	__wcschr_c
ce426f
+END(__wcschr_vx)
ce426f
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
ce426f
diff --git a/sysdeps/s390/multiarch/wcschr.c b/sysdeps/s390/multiarch/wcschr.c
ce426f
new file mode 100644
ce426f
index 0000000..9c8c097
ce426f
--- /dev/null
ce426f
+++ b/sysdeps/s390/multiarch/wcschr.c
ce426f
@@ -0,0 +1,27 @@
ce426f
+/* Multiple versions of wcschr.
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_ifunc2 (__wcschr, wcschr)
ce426f
+
ce426f
+#else
ce426f
+# include <wcsmbs/wcschr.c>
ce426f
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
ce426f
-- 
ce426f
2.3.0
ce426f