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