unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option
@ 2019-03-13 14:03 Adhemerval Zanella
  2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This allows an architecture the use the old generic implementation
and also set explicit loop unrolling.

Checked on aarch64-linux-gnu.

	* include/loop_unroll.h: New file.
	* wcsmbs/wcscpy (__wcscpy): Add option to use loop unrolling
	besides generic implementation.
---
 include/loop_unroll.h | 78 +++++++++++++++++++++++++++++++++++++++++++
 wcsmbs/wcscpy.c       | 19 +++++++++++
 2 files changed, 97 insertions(+)
 create mode 100644 include/loop_unroll.h

diff --git a/include/loop_unroll.h b/include/loop_unroll.h
new file mode 100644
index 0000000000..f40d375257
--- /dev/null
+++ b/include/loop_unroll.h
@@ -0,0 +1,78 @@
+/* Macro for explicit loop unrolling.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _LOOP_UNROLL_H
+#define _LOOP_UNROLL_H
+
+/* Loop unroll macro to be used for explicity force loop unrolling with a
+   configurable number or iterations.  The idea is to make the loop unrolling
+   independent of whether compiler is able to unrolling through specific
+   optimizations options (-funroll-loops or -funroll-all-loops).
+
+   For instance, to implement strcpy with SRC being the source input and 
+   DEST the destination buffer, it is expected the macro to be used in this
+   way:
+
+     #define ITERATION(index)	\
+       ({ char c = *str++; *dest++ = c; c != '\0' })
+
+     while (1)
+       UNROLL_REPEAT (4, ITERATION)
+
+   The loop will be manually unrolled 4 times.  Another option is to do
+   the index update after the tests:
+
+     #define ITERATION(index)	\
+       ({ char c = *(str + index); *(dest + index) = c; c != '\0' })
+     #define UPDATE(n)		\
+       str += n; dst += n
+
+     while (1)
+       UNROLL_REPEAT_UPDATE (4, ITERATION, UPDATE)
+
+   The loop will be manually unrolled 4 times and the SRC and DEST pointers
+   will be update only after last iteration.
+
+   Currently both macros unrolls the loop 8 times at maximum.  */
+
+#define UNROLL_REPEAT_1(X)    if (!X(0)) break;
+#define UNROLL_REPEAT_2(X)    UNROLL_REPEAT_1(X) if (!X(1)) break;
+#define UNROLL_REPEAT_3(X)    UNROLL_REPEAT_2(X) if (!X(2)) break;
+#define UNROLL_REPEAT_4(X)    UNROLL_REPEAT_3(X) if (!X(3)) break;
+#define UNROLL_REPEAT_5(X)    UNROLL_REPEAT_4(X) if (!X(4)) break;
+#define UNROLL_REPEAT_6(X)    UNROLL_REPEAT_5(X) if (!X(5)) break;
+#define UNROLL_REPEAT_7(X)    UNROLL_REPEAT_6(X) if (!X(6)) break;
+#define UNROLL_REPEAT_8(X)    UNROLL_REPEAT_7(X) if (!X(7)) break;
+
+#define UNROLL_EXPAND(...)    __VA_ARGS__
+
+#define UNROLL_REPEAT__(N, X) UNROLL_EXPAND(UNROLL_REPEAT_ ## N) (X)
+#define UNROLL_REPEAT_(N, X)  UNROLL_REPEAT__ (N, X)
+
+#define UNROLL_REPEAT(N, X)                \
+  (void) ({                                \
+    UNROLL_REPEAT_(UNROLL_EXPAND(N), X);   \
+  })
+
+#define UNROLL_REPEAT_UPDATE(N, X, U)      \
+  (void) ({                                \
+    UNROLL_REPEAT_ (UNROLL_EXPAND(N), X);  \
+    UPDATE (N);                            \
+  })
+
+#endif
diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c
index 6fb2969513..8e8719744e 100644
--- a/wcsmbs/wcscpy.c
+++ b/wcsmbs/wcscpy.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 
 #ifdef WCSCPY
@@ -27,7 +28,25 @@
 wchar_t *
 __wcscpy (wchar_t *dest, const wchar_t *src)
 {
+#ifndef UNROLL_NTIMES
   return __wmemcpy (dest, src, __wcslen (src) + 1);
+#else
+  /* Some architectures might have costly tail function call (powerpc
+     for instance) where wmemcpy call overhead for smalls sizes might
+     be costly than just unroll the main loop.  */
+  wchar_t *wcp = dest;
+
+#define ITERATION(index)		\
+  ({					\
+     wchar_t c = *src++;		\
+     *wcp++ = c;			\
+     c != L'\0';			\
+  })
+
+  while (1)
+    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
+  return dest;
+#endif
 }
 #ifndef WCSCPY
 weak_alias (__wcscpy, wcscpy)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/6] powerpc: Use generic wcscpy optimization
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
@ 2019-03-13 14:03 ` Adhemerval Zanella
  2019-03-23 14:56   ` Gabriel F. T. Gomes
  2019-03-13 14:03 ` [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr Adhemerval Zanella
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This patch removes the power6 wcscpy optimization and use generic
implementation instead.  Currently both power6 and power7 ifunc variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcscpy.c):
	New rule.
	* sysdeps/powerpc/power6/wcscpy.c: Remove file.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcscpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/power6/wcscpy.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcscpy-power6 and
	wcscpy-power7.
	(CFLAGS-wcscpy-power7.c, CFLAGS-wcscpy-power6.c): Remove rule.
	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
	Remove wcscpy optimizations.
---
 sysdeps/powerpc/Makefile                      |   4 +
 sysdeps/powerpc/power6/wcscpy.c               | 105 ------------------
 .../powerpc32/power4/multiarch/Makefile       |   5 +-
 .../power4/multiarch/ifunc-impl-list.c        |  11 --
 .../power4/multiarch/wcscpy-power6.c          |  22 ----
 .../power4/multiarch/wcscpy-power7.c          |  22 ----
 .../powerpc32/power4/multiarch/wcscpy-ppc32.c |  27 -----
 .../powerpc32/power4/multiarch/wcscpy.c       |  36 ------
 sysdeps/powerpc/powerpc64/multiarch/Makefile  |   5 +-
 .../powerpc64/multiarch/ifunc-impl-list.c     |  11 --
 .../powerpc64/multiarch/wcscpy-power6.c       |  19 ----
 .../powerpc64/multiarch/wcscpy-power7.c       |  19 ----
 .../powerpc64/multiarch/wcscpy-ppc64.c        |  18 ---
 sysdeps/powerpc/powerpc64/multiarch/wcscpy.c  |  35 ------
 sysdeps/powerpc/powerpc64/power6/wcscpy.c     |   4 -
 15 files changed, 6 insertions(+), 337 deletions(-)
 delete mode 100644 sysdeps/powerpc/power6/wcscpy.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/wcscpy.c

diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
index bac5a3a73c..ba137e4cad 100644
--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -46,3 +46,7 @@ sysdep_headers += sys/platform/ppc.h
 tests += test-gettimebase
 tests += tst-set_ppr
 endif
+
+ifeq ($(subdir),wcsmbs)
+CFLAGS-wcscpy.c += -DUNROLL_NTIMES=8
+endif
diff --git a/sysdeps/powerpc/power6/wcscpy.c b/sysdeps/powerpc/power6/wcscpy.c
deleted file mode 100644
index 11c04b081a..0000000000
--- a/sysdeps/powerpc/power6/wcscpy.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* wcscpy.c - Wide Character Copy for POWER6+.
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <stddef.h>
-#include <wchar.h>
-
-#ifndef WCSCPY
-# define WCSCPY wcscpy
-#endif
-
-/* Copy SRC to DEST.  */
-wchar_t *
-WCSCPY (wchar_t *dest, const wchar_t *src)
-{
-  wint_t c,d;
-  wchar_t *wcp, *wcp2;
-
-  if (__alignof__ (wchar_t) >= sizeof (wchar_t))
-    {
-      const ptrdiff_t off = dest - src;
-
-      wcp = (wchar_t *) src;
-      wcp2 = wcp + 1 ;
-
-      do
-        {
-          d = *wcp;
-          wcp[off] = d;
-          if (d == L'\0')
-            return dest;
-          wcp += 2;
-
-          c = *wcp2;
-          wcp2[off] = c;
-          if (c == L'\0')
-            return dest;
-          wcp2 += 2;
-
-          d = *wcp;
-          wcp[off] = d;
-          if (d == L'\0')
-            return dest;
-          wcp += 2;
-
-          c = *wcp2;
-          wcp2[off] = c;
-          if (c == L'\0')
-            return dest;
-          wcp2 += 2;
-
-          d = *wcp;
-          wcp[off] = d;
-          if (d == L'\0')
-            return dest;
-          wcp += 2;
-
-          c = *wcp2;
-          wcp2[off] = c;
-          if (c == L'\0')
-            return dest;
-          wcp2 += 2;
-
-          d = *wcp;
-          wcp[off] = d;
-          if (d == L'\0')
-            return dest;
-          wcp += 2;
-
-          c = *wcp2;
-          wcp2[off] = c;
-          if (c == L'\0')
-            return dest;
-          wcp2 += 2;
-        }
-      while (c != L'\0');
-
-    }
-  else
-    {
-      wcp = dest;
-
-      do
-        {
-          c = *src++;
-          *wcp++ = c;
-        }
-      while (c != L'\0');
-    }
-  return dest;
-}
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
index bd9d360efa..f5141bc5b5 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
@@ -18,13 +18,10 @@ endif
 
 ifeq ($(subdir),wcsmbs)
 sysdep_routines += wcschr-power7 wcschr-power6 wcschr-ppc32 \
-		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc32 \
-		   wcscpy-power7 wcscpy-power6 wcscpy-ppc32
+		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc32
 
 CFLAGS-wcschr-power7.c += -mcpu=power7
 CFLAGS-wcschr-power6.c += -mcpu=power6
 CFLAGS-wcsrchr-power7.c += -mcpu=power7
 CFLAGS-wcsrchr-power6.c += -mcpu=power6
-CFLAGS-wcscpy-power7.c += -mcpu=power7
-CFLAGS-wcscpy-power6.c += -mcpu=power6
 endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index bcd38e0f79..ae581d62f8 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -209,16 +209,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
 			      __wcsrchr_ppc))
 
-  /* Support sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c.  */
-  IFUNC_IMPL (i, name, wcscpy,
-	      IFUNC_IMPL_ADD (array, i, wcscpy,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcscpy_power7)
-	      IFUNC_IMPL_ADD (array, i, wcscpy,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcscpy_power6)
-	      IFUNC_IMPL_ADD (array, i, wcscpy, 1,
-			      __wcscpy_ppc))
-
   return i;
 }
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c
deleted file mode 100644
index 5bb0c82462..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#define WCSCPY __wcscpy_power6
-
-#include <sysdeps/powerpc/power6/wcscpy.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c
deleted file mode 100644
index 5375094b60..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#define WCSCPY __wcscpy_power7
-
-#include <sysdeps/powerpc/power6/wcscpy.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
deleted file mode 100644
index 31e0d81ef0..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-extern __typeof (wcscpy) __wcscpy_ppc;
-
-#define WCSCPY  __wcscpy_ppc
-#include <wcsmbs/wcscpy.c>
-
-#ifdef SHARED
-__hidden_ver1 (__wcscpy_ppc, __GI___wcscpy, __wcscpy_ppc);
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
deleted file mode 100644
index 0daf55cf70..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Multiple versions of wcscpy
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if IS_IN (libc)
-# define __wcscpy __redirect_wcscpy
-# include <wchar.h>
-# undef __wcscpy
-# include "init-arch.h"
-
-extern __typeof (__redirect_wcscpy) __wcscpy_ppc attribute_hidden;
-extern __typeof (__redirect_wcscpy) __wcscpy_power6 attribute_hidden;
-extern __typeof (__redirect_wcscpy) __wcscpy_power7 attribute_hidden;
-
-libc_ifunc_redirected (__redirect_wcscpy, __wcscpy,
-		       (hwcap & PPC_FEATURE_HAS_VSX)
-		       ? __wcscpy_power7 :
-			 (hwcap & PPC_FEATURE_ARCH_2_05)
-			 ? __wcscpy_power6
-		       : __wcscpy_ppc);
-weak_alias (__wcscpy, wcscpy)
-#endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
index 963ea84dbf..3913ef580e 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -40,13 +40,10 @@ endif
 
 ifeq ($(subdir),wcsmbs)
 sysdep_routines += wcschr-power7 wcschr-power6 wcschr-ppc64 \
-		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc64 \
-		   wcscpy-power7 wcscpy-power6 wcscpy-ppc64 \
+		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc64
 
 CFLAGS-wcschr-power7.c += -mcpu=power7
 CFLAGS-wcschr-power6.c += -mcpu=power6
 CFLAGS-wcsrchr-power7.c += -mcpu=power7
 CFLAGS-wcsrchr-power6.c += -mcpu=power6
-CFLAGS-wcscpy-power7.c += -mcpu=power7
-CFLAGS-wcscpy-power6.c += -mcpu=power6
 endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index 8d91d9abb9..06d33d71e0 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -282,17 +282,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
 			      __wcsrchr_ppc))
 
-  /* Support sysdeps/powerpc/powerpc64/multiarch/wcscpy.c.  */
-  IFUNC_IMPL (i, name, wcscpy,
-	      IFUNC_IMPL_ADD (array, i, wcscpy,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcscpy_power7)
-	      IFUNC_IMPL_ADD (array, i, wcscpy,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcscpy_power6)
-	      IFUNC_IMPL_ADD (array, i, wcscpy, 1,
-			      __wcscpy_ppc))
-
   /* Support sysdeps/powerpc/powerpc64/multiarch/strrchr.c.  */
   IFUNC_IMPL (i, name, strrchr,
 	      IFUNC_IMPL_ADD (array, i, strrchr,
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c b/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c
deleted file mode 100644
index abe2e0f073..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcscpy.c - Wide Character Search for powerpc64/power6.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c b/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c
deleted file mode 100644
index be95cd9074..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcscpy.c - Wide Character Search for powerpc64/power7.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c
deleted file mode 100644
index faa3c1614f..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c b/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
deleted file mode 100644
index 3f918b27c6..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcscpy.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Multiple versions of wcscpy.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define __wcscpy __redirect___wcscpy
-#include <wchar.h>
-#undef __wcscpy
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (wcscpy) __wcscpy_ppc attribute_hidden;
-extern __typeof (wcscpy) __wcscpy_power6 attribute_hidden;
-extern __typeof (wcscpy) __wcscpy_power7 attribute_hidden;
-
-libc_ifunc_redirected (__redirect___wcscpy, __wcscpy,
-		       (hwcap & PPC_FEATURE_HAS_VSX)
-		       ? __wcscpy_power7 :
-		         (hwcap & PPC_FEATURE_ARCH_2_05)
-		         ? __wcscpy_power6
-	               : __wcscpy_ppc);
-weak_alias (__wcscpy, wcscpy)
diff --git a/sysdeps/powerpc/powerpc64/power6/wcscpy.c b/sysdeps/powerpc/powerpc64/power6/wcscpy.c
deleted file mode 100644
index 59cfb28832..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/wcscpy.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define WCSCPY __wcscpy
-#include <sysdeps/powerpc/power6/wcscpy.c>
-libc_hidden_def (__wcscpy)
-weak_alias (__wcscpy, wcscpy)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
  2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
@ 2019-03-13 14:03 ` Adhemerval Zanella
  2019-03-23 15:00   ` Gabriel F. T. Gomes
  2019-03-13 14:03 ` [PATCH v2 4/6] powerpc: Use generic wcschr optimization Adhemerval Zanella
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

	* wcsmbs/wcschr.c (WCSCHR): Use loop_unroll.h to parametrize
	the loop unroll.
---
 wcsmbs/wcschr.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/wcsmbs/wcschr.c b/wcsmbs/wcschr.c
index cd66b2a58c..9de302298d 100644
--- a/wcsmbs/wcschr.c
+++ b/wcsmbs/wcschr.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 #ifndef WCSCHR
 # define WCSCHR __wcschr
@@ -25,12 +26,23 @@
 wchar_t *
 WCSCHR (const wchar_t *wcs, const wchar_t wc)
 {
-  do
-    if (*wcs == wc)
-      return (wchar_t *) wcs;
-  while (*wcs++ != L'\0');
+  wchar_t *dest = NULL;
 
-  return NULL;
+#define ITERATION(index)		\
+  ({					\
+    if (*wcs == wc)			\
+      dest = (wchar_t*) wcs;		\
+    dest == NULL && *wcs++ != L'\0';	\
+  })
+
+#ifndef UNROLL_NTIMES
+# define UNROLL_NTIMES 1
+#endif
+
+  while (1)
+    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
+
+  return dest;
 }
 libc_hidden_def (__wcschr)
 weak_alias (__wcschr, wcschr)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 4/6] powerpc: Use generic wcschr optimization
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
  2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
  2019-03-13 14:03 ` [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr Adhemerval Zanella
@ 2019-03-13 14:03 ` Adhemerval Zanella
  2019-03-23 15:00   ` Gabriel F. T. Gomes
  2019-03-13 14:03 ` [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr Adhemerval Zanella
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This patch removes the power6 wcschr optimization and use generic
implementation instead.  Currently both power6 and power7 ifunc variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
	New rule.
	* sysdeps/powerpc/power6/wcschr.c: Remove file.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcschr.c: Likewise.
	* sysdeps/powerpc/powerpc64/power6/wcschr.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcschr-power6 and
	wcschr-power7.
	(CFLAGS-wcschr-power7.c, CFLAGS-wcschr-power6.c): Remove rule.
	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
	Remove wcschr optimizations.
---
 sysdeps/powerpc/Makefile                      |  1 +
 sysdeps/powerpc/power6/wcschr.c               | 96 -------------------
 .../powerpc32/power4/multiarch/Makefile       |  5 +-
 .../power4/multiarch/ifunc-impl-list.c        | 11 ---
 .../power4/multiarch/wcschr-power6.c          | 26 -----
 .../power4/multiarch/wcschr-power7.c          | 26 -----
 .../powerpc32/power4/multiarch/wcschr-ppc32.c | 43 ---------
 .../powerpc32/power4/multiarch/wcschr.c       | 41 --------
 sysdeps/powerpc/powerpc64/multiarch/Makefile  |  5 +-
 .../powerpc64/multiarch/ifunc-impl-list.c     | 11 ---
 .../powerpc64/multiarch/wcschr-power6.c       | 19 ----
 .../powerpc64/multiarch/wcschr-power7.c       | 19 ----
 .../powerpc64/multiarch/wcschr-ppc64.c        | 18 ----
 sysdeps/powerpc/powerpc64/multiarch/wcschr.c  | 43 ---------
 sysdeps/powerpc/powerpc64/power6/wcschr.c     |  1 -
 15 files changed, 3 insertions(+), 362 deletions(-)
 delete mode 100644 sysdeps/powerpc/power6/wcschr.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcschr.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/wcschr.c

diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
index ba137e4cad..35cf1c624b 100644
--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -49,4 +49,5 @@ endif
 
 ifeq ($(subdir),wcsmbs)
 CFLAGS-wcscpy.c += -DUNROLL_NTIMES=8
+CFLAGS-wcschr.c += -DUNROLL_NTIMES=8
 endif
diff --git a/sysdeps/powerpc/power6/wcschr.c b/sysdeps/powerpc/power6/wcschr.c
deleted file mode 100644
index e3f93569dd..0000000000
--- a/sysdeps/powerpc/power6/wcschr.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* wcschr.c - Wide Character Search for POWER6+.
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#ifndef WCSCHR
-# define WCSCHR __wcschr
-# define DEFAULT_WCSCHR
-#endif
-
-/* Find the first occurrence of WC in WCS.  */
-wchar_t *
-WCSCHR (const wchar_t *wcs, const wchar_t wc)
-{
-  const wchar_t *wcs2 = wcs + 1;
-
-  if (*wcs == wc)
-    return (wchar_t *) wcs;
-  if (*wcs == L'\0')
-    return NULL;
-
-  do
-    {
-      wcs += 2;
-
-      if (*wcs2 == wc)
-        return (wchar_t *) wcs2;
-      if (*wcs2 == L'\0')
-        return NULL;
-       wcs2 += 2;
-
-      if (*wcs == wc)
-        return (wchar_t *) wcs;
-      if (*wcs == L'\0')
-        return NULL;
-      wcs += 2;
-
-      if (*wcs2 == wc)
-        return (wchar_t *) wcs2;
-      if (*wcs2 == L'\0')
-        return NULL;
-      wcs2 += 2;
-
-      if (*wcs == wc)
-        return (wchar_t *) wcs;
-      if (*wcs == L'\0')
-        return NULL;
-      wcs += 2;
-
-      if (*wcs2 == wc)
-        return (wchar_t *) wcs2;
-      if (*wcs2 == L'\0')
-        return NULL;
-      wcs2 += 2;
-
-      if (*wcs == wc)
-        return (wchar_t *) wcs;
-      if (*wcs == L'\0')
-        return NULL;
-      wcs += 2;
-
-      if (*wcs2 == wc)
-        return (wchar_t *) wcs2;
-      if (*wcs2 == L'\0')
-        return NULL;
-      wcs2 += 2;
-
-      if (*wcs == wc)
-        return (wchar_t *) wcs;
-    }
-  while (*wcs != L'\0');
-
-  return NULL;
-}
-#ifdef DEFAULT_WCSCHR
-libc_hidden_def (__wcschr)
-weak_alias (__wcschr, wcschr)
-libc_hidden_weak (wcschr)
-#else
-libc_hidden_def (wcschr)
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
index f5141bc5b5..bb87c56b4d 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
@@ -17,11 +17,8 @@ CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
 endif
 
 ifeq ($(subdir),wcsmbs)
-sysdep_routines += wcschr-power7 wcschr-power6 wcschr-ppc32 \
-		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc32
+sysdep_routines += wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc32
 
-CFLAGS-wcschr-power7.c += -mcpu=power7
-CFLAGS-wcschr-power6.c += -mcpu=power6
 CFLAGS-wcsrchr-power7.c += -mcpu=power7
 CFLAGS-wcsrchr-power6.c += -mcpu=power6
 endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index ae581d62f8..7624c3d5f0 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -187,17 +187,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, strchr, 1,
 			      __strchr_ppc))
 
-  /* Support sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c.  */
-  IFUNC_IMPL (i, name, wcschr,
-	      IFUNC_IMPL_ADD (array, i, wcschr,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcschr_power7)
-	      IFUNC_IMPL_ADD (array, i, wcschr,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcschr_power6)
-	      IFUNC_IMPL_ADD (array, i, wcschr, 1,
-			      __wcschr_ppc))
-
   /* Support sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c.  */
   IFUNC_IMPL (i, name, wcsrchr,
 	      IFUNC_IMPL_ADD (array, i, wcsrchr,
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c
deleted file mode 100644
index 516f0f8584..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* wcschr.c - Wide Character Search for powerpc32/power6.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#define WCSCHR __wcschr_power6
-
-#undef libc_hidden_def
-#define libc_hidden_def(name)
-
-#include <sysdeps/powerpc/power6/wcschr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c
deleted file mode 100644
index 5dc52659e8..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* wcschr.c - Wide Character Search for powerpc32/power7.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#define WCSCHR __wcschr_power7
-
-#undef libc_hidden_def
-#define libc_hidden_def(name)
-
-#include <sysdeps/powerpc/power6/wcschr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c
deleted file mode 100644
index 55873fbcf4..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#if IS_IN (libc)
-# undef libc_hidden_weak
-# define libc_hidden_weak(name)
-
-# undef weak_alias
-# undef libc_hidden_def
-
-# ifdef SHARED
-#  define libc_hidden_def(name)  \
-    __hidden_ver1 (__wcschr_ppc, __GI_wcschr, __wcschr_ppc); \
-    strong_alias (__wcschr_ppc, __wcschr_ppc_1); \
-    __hidden_ver1 (__wcschr_ppc_1, __GI___wcschr, __wcschr_ppc_1);
-#  define weak_alias(name,alias)
-# else
-#  define weak_alias(name, alias) \
-    _weak_alias(__wcschr_ppc, __wcschr)
-#  define libc_hidden_def(name)
-# endif /* SHARED  */
-#endif
-
-extern __typeof (wcschr) __wcschr_ppc;
-
-#define WCSCHR  __wcschr_ppc
-#include <wcsmbs/wcschr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c
deleted file mode 100644
index c8379a2dca..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Multiple versions of wcschr
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if IS_IN (libc)
-# define wcschr __redirect_wcschr
-# include <wchar.h>
-# include <shlib-compat.h>
-# include "init-arch.h"
-
-extern __typeof (__redirect_wcschr) __wcschr_ppc attribute_hidden;
-extern __typeof (__redirect_wcschr) __wcschr_power6 attribute_hidden;
-extern __typeof (__redirect_wcschr) __wcschr_power7 attribute_hidden;
-
-extern __typeof (__redirect_wcschr) __libc_wcschr;
-
-libc_ifunc (__libc_wcschr,
-	     (hwcap & PPC_FEATURE_HAS_VSX)
-             ? __wcschr_power7 :
-	       (hwcap & PPC_FEATURE_ARCH_2_05)
-	       ? __wcschr_power6
-             : __wcschr_ppc);
-#undef wcschr
-weak_alias (__libc_wcschr, wcschr)
-#else
-#include <wcsmbs/wcschr.c>
-#endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
index 3913ef580e..c70f4a2b5a 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -39,11 +39,8 @@ CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
 endif
 
 ifeq ($(subdir),wcsmbs)
-sysdep_routines += wcschr-power7 wcschr-power6 wcschr-ppc64 \
-		   wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc64
+sysdep_routines += wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc64
 
-CFLAGS-wcschr-power7.c += -mcpu=power7
-CFLAGS-wcschr-power6.c += -mcpu=power6
 CFLAGS-wcsrchr-power7.c += -mcpu=power7
 CFLAGS-wcsrchr-power6.c += -mcpu=power6
 endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index 06d33d71e0..9b1e4d141d 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -260,17 +260,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
 			      __strncasecmp_l_ppc))
 
-  /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c.  */
-  IFUNC_IMPL (i, name, wcschr,
-	      IFUNC_IMPL_ADD (array, i, wcschr,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcschr_power7)
-	      IFUNC_IMPL_ADD (array, i, wcschr,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcschr_power6)
-	      IFUNC_IMPL_ADD (array, i, wcschr, 1,
-			      __wcschr_ppc))
-
   /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c.  */
   IFUNC_IMPL (i, name, wcsrchr,
 	      IFUNC_IMPL_ADD (array, i, wcsrchr,
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c b/sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c
deleted file mode 100644
index 029608c512..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcschr.c - Wide Character Search for powerpc64/power6.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c b/sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c
deleted file mode 100644
index 9b11103976..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcschr.c - Wide Character Search for powerpc64/power7.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c
deleted file mode 100644
index f956fc0aa2..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcschr.c b/sysdeps/powerpc/powerpc64/multiarch/wcschr.c
deleted file mode 100644
index 0a279f0dd2..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcschr.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Multiple versions of wcschr
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if IS_IN (libc)
-# define wcschr __redirect_wcschr
-# define __wcschr __redirect___wcschr
-# include <wchar.h>
-# include <shlib-compat.h>
-# include "init-arch.h"
-
-extern __typeof (wcschr) __wcschr_ppc attribute_hidden;
-extern __typeof (wcschr) __wcschr_power6 attribute_hidden;
-extern __typeof (wcschr) __wcschr_power7 attribute_hidden;
-# undef wcschr
-# undef __wcschr
-
-libc_ifunc_redirected (__redirect___wcschr, __wcschr,
-		       (hwcap & PPC_FEATURE_HAS_VSX)
-		       ? __wcschr_power7
-		       : (hwcap & PPC_FEATURE_ARCH_2_05)
-			 ? __wcschr_power6
-			 : __wcschr_ppc);
-weak_alias (__wcschr, wcschr)
-#else
-#undef libc_hidden_def
-#define libc_hidden_def(a)
-#include <wcsmbs/wcschr.c>
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power6/wcschr.c b/sysdeps/powerpc/powerpc64/power6/wcschr.c
deleted file mode 100644
index ae04a130cc..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/wcschr.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/powerpc/power6/wcschr.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2019-03-13 14:03 ` [PATCH v2 4/6] powerpc: Use generic wcschr optimization Adhemerval Zanella
@ 2019-03-13 14:03 ` Adhemerval Zanella
  2019-03-23 15:00   ` Gabriel F. T. Gomes
  2019-03-13 14:03 ` [PATCH v2 6/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
  2019-03-23 15:00 ` [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Gabriel F. T. Gomes
  5 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

	* wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize
	the loop unroll.
---
 wcsmbs/wcsrchr.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/wcsmbs/wcsrchr.c b/wcsmbs/wcsrchr.c
index 0d4bad0704..3175df357d 100644
--- a/wcsmbs/wcsrchr.c
+++ b/wcsmbs/wcsrchr.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 #ifndef WCSRCHR
 # define WCSRCHR wcsrchr
@@ -26,12 +27,21 @@
 wchar_t *
 WCSRCHR (const wchar_t *wcs, const wchar_t wc)
 {
-  const wchar_t *retval = NULL;
+  wchar_t *retval = NULL;
 
-  do
-    if (*wcs == wc)
-      retval = wcs;
-  while (*wcs++ != L'\0');
+#define ITERATION(index)		\
+  ({					\
+    if (*wcs == wc)			\
+      retval = (wchar_t*) wcs;		\
+    *wcs++ != L'\0';	\
+  })
 
-  return (wchar_t *) retval;
+#ifndef UNROLL_NTIMES
+# define UNROLL_NTIMES 1
+#endif
+
+  while (1)
+    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
+
+  return retval;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 6/6] powerpc: Use generic wcscpy optimization
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2019-03-13 14:03 ` [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr Adhemerval Zanella
@ 2019-03-13 14:03 ` Adhemerval Zanella
  2019-03-23 15:01   ` Gabriel F. T. Gomes
  2019-03-23 15:00 ` [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Gabriel F. T. Gomes
  5 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2019-03-13 14:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: Gabriel F . T . Gomes

This patch removes the power6 wcsrchr optimization and use generic
implementation instead.  Currently both power6 and power7 ifunc variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
	New rule.
	* sysdeps/powerpc/power6/wcsrchr.c: Remove file.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c: Likewise.
	* sysdeps/powerpc/powerpc64/power6/wcsrchr.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcsrchr-power6 and
	wcsrchr-power7.
	(CFLAGS-wcsrchr-power7.c, CFLAGS-wcsrchr-power6.c): Remove rule.
	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
	Remove wcsrchr optimizations.
---
 sysdeps/powerpc/Makefile                      |  1 +
 sysdeps/powerpc/power6/wcsrchr.c              | 89 -------------------
 .../powerpc32/power4/multiarch/Makefile       |  7 --
 .../power4/multiarch/ifunc-impl-list.c        | 11 ---
 .../power4/multiarch/wcsrchr-power6.c         | 20 -----
 .../power4/multiarch/wcsrchr-power7.c         | 20 -----
 .../power4/multiarch/wcsrchr-ppc32.c          | 26 ------
 .../powerpc32/power4/multiarch/wcsrchr.c      | 36 --------
 sysdeps/powerpc/powerpc64/multiarch/Makefile  |  7 --
 .../powerpc64/multiarch/ifunc-impl-list.c     | 11 ---
 .../powerpc64/multiarch/wcsrchr-power6.c      | 19 ----
 .../powerpc64/multiarch/wcsrchr-power7.c      | 19 ----
 .../powerpc64/multiarch/wcsrchr-ppc64.c       | 18 ----
 sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c | 36 --------
 sysdeps/powerpc/powerpc64/power6/wcsrchr.c    |  1 -
 15 files changed, 1 insertion(+), 320 deletions(-)
 delete mode 100644 sysdeps/powerpc/power6/wcsrchr.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
 delete mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
 delete mode 100644 sysdeps/powerpc/powerpc64/power6/wcsrchr.c

diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
index 35cf1c624b..05675bc8ae 100644
--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -50,4 +50,5 @@ endif
 ifeq ($(subdir),wcsmbs)
 CFLAGS-wcscpy.c += -DUNROLL_NTIMES=8
 CFLAGS-wcschr.c += -DUNROLL_NTIMES=8
+CFLAGS-wcsrchr.c += -DUNROLL_NTIMES=8
 endif
diff --git a/sysdeps/powerpc/power6/wcsrchr.c b/sysdeps/powerpc/power6/wcsrchr.c
deleted file mode 100644
index 1762bd276c..0000000000
--- a/sysdeps/powerpc/power6/wcsrchr.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* wcsrchr.c - Wide Character Reverse Search for POWER6+.
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#ifndef WCSRCHR
-# define WCSRCHR wcsrchr
-#endif
-
-/* Find the last occurrence of WC in WCS.  */
-wchar_t *
-WCSRCHR (const wchar_t *wcs, const wchar_t wc)
-{
-  const wchar_t *wcs2 = wcs + 1;
-  const wchar_t *retval = NULL;
-
-  if (*wcs == wc)
-    retval = wcs;
-
-  if (*wcs == L'\0') return (wchar_t *) retval;
-
-  do
-    {
-    wcs+=2;
-
-    if (*wcs2 == wc)
-      retval = wcs2;
-    if (*wcs2 == L'\0')
-      return (wchar_t *) retval;
-    wcs2+=2;
-
-    if (*wcs == wc)
-      retval = wcs;
-    if (*wcs == L'\0')
-      return (wchar_t *) retval;
-    wcs+=2;
-
-    if (*wcs2 == wc)
-      retval = wcs2;
-    if (*wcs2 == L'\0')
-      return (wchar_t *) retval;
-    wcs2+=2;
-
-    if (*wcs == wc)
-      retval = wcs;
-    if (*wcs == L'\0')
-      return (wchar_t *) retval;
-    wcs+=2;
-
-    if (*wcs2 == wc)
-      retval = wcs2;
-    if (*wcs2 == L'\0')
-      return (wchar_t *) retval;
-    wcs2+=2;
-
-    if (*wcs == wc)
-      retval = wcs;
-    if (*wcs == L'\0')
-      return (wchar_t *) retval;
-    wcs+=2;
-
-    if (*wcs2 == wc)
-      retval = wcs2;
-    if (*wcs2 == L'\0')
-      return (wchar_t *) retval;
-    wcs2+=2;
-
-    if (*wcs == wc)
-      retval = wcs;
-    }
-  while (*wcs != L'\0');
-
-  return (wchar_t *) retval;
-}
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
index bb87c56b4d..5c68f07d19 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
@@ -15,10 +15,3 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
 endif
-
-ifeq ($(subdir),wcsmbs)
-sysdep_routines += wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc32
-
-CFLAGS-wcsrchr-power7.c += -mcpu=power7
-CFLAGS-wcsrchr-power6.c += -mcpu=power6
-endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
index 7624c3d5f0..16a64beb33 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
@@ -187,16 +187,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, strchr, 1,
 			      __strchr_ppc))
 
-  /* Support sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c.  */
-  IFUNC_IMPL (i, name, wcsrchr,
-	      IFUNC_IMPL_ADD (array, i, wcsrchr,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcsrchr_power7)
-	      IFUNC_IMPL_ADD (array, i, wcsrchr,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcsrchr_power6)
-	      IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
-			      __wcsrchr_ppc))
-
   return i;
 }
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
deleted file mode 100644
index 93c8bde9ba..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define WCSRCHR      __wcsrchr_power6
-
-#include <sysdeps/powerpc/power6/wcsrchr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
deleted file mode 100644
index a32a9845b7..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define WCSRCHR      __wcsrchr_power7
-
-#include <sysdeps/powerpc/power6/wcsrchr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
deleted file mode 100644
index 690faf48b8..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <wchar.h>
-
-#if IS_IN (libc)
-# define WCSRCHR  __wcsrchr_ppc
-#endif
-
-extern __typeof (wcsrchr) __wcsrchr_ppc;
-
-#include <wcsmbs/wcsrchr.c>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c b/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c
deleted file mode 100644
index 80adc7bcd1..0000000000
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Multiple versions of wcsrchr
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if IS_IN (libc)
-# include <wchar.h>
-# include <shlib-compat.h>
-# include "init-arch.h"
-
-extern __typeof (wcsrchr) __wcsrchr_ppc attribute_hidden;
-extern __typeof (wcsrchr) __wcsrchr_power6 attribute_hidden;
-extern __typeof (wcsrchr) __wcsrchr_power7 attribute_hidden;
-
-libc_ifunc (wcsrchr,
-	     (hwcap & PPC_FEATURE_HAS_VSX)
-             ? __wcsrchr_power7 :
-	       (hwcap & PPC_FEATURE_ARCH_2_05)
-	       ? __wcsrchr_power6
-             : __wcsrchr_ppc);
-#else
-#include <wcsmbs/wcsrchr.c>
-#endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
index c70f4a2b5a..ea936bf9ed 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -37,10 +37,3 @@ endif
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
 endif
-
-ifeq ($(subdir),wcsmbs)
-sysdep_routines += wcsrchr-power7 wcsrchr-power6 wcsrchr-ppc64
-
-CFLAGS-wcsrchr-power7.c += -mcpu=power7
-CFLAGS-wcsrchr-power6.c += -mcpu=power6
-endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index 9b1e4d141d..c0a927d73e 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -260,17 +260,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 	      IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
 			      __strncasecmp_l_ppc))
 
-  /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c.  */
-  IFUNC_IMPL (i, name, wcsrchr,
-	      IFUNC_IMPL_ADD (array, i, wcsrchr,
-			      hwcap & PPC_FEATURE_HAS_VSX,
-			      __wcsrchr_power7)
-	      IFUNC_IMPL_ADD (array, i, wcsrchr,
-			      hwcap & PPC_FEATURE_ARCH_2_05,
-			      __wcsrchr_power6)
-	      IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
-			      __wcsrchr_ppc))
-
   /* Support sysdeps/powerpc/powerpc64/multiarch/strrchr.c.  */
   IFUNC_IMPL (i, name, strrchr,
 	      IFUNC_IMPL_ADD (array, i, strrchr,
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c b/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
deleted file mode 100644
index a68569d30c..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcsrchr.c - Wide Character Search for powerpc64/power6.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c b/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
deleted file mode 100644
index f27553f4ab..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* wcsrchr.c - Wide Character Search for powerpc64/power7.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
deleted file mode 100644
index b6504ebaef..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c b/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
deleted file mode 100644
index 52371a18b7..0000000000
--- a/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Multiple versions of wcsrchr.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if IS_IN (libc)
-# include <wchar.h>
-# include <shlib-compat.h>
-# include "init-arch.h"
-
-extern __typeof (wcsrchr) __wcsrchr_ppc attribute_hidden;
-extern __typeof (wcsrchr) __wcsrchr_power6 attribute_hidden;
-extern __typeof (wcsrchr) __wcsrchr_power7 attribute_hidden;
-
-libc_ifunc (wcsrchr,
-	     (hwcap & PPC_FEATURE_HAS_VSX)
-             ? __wcsrchr_power7 :
-	       (hwcap & PPC_FEATURE_ARCH_2_05)
-	       ? __wcsrchr_power6
-             : __wcsrchr_ppc);
-#else
-#include <wcsmbs/wcsrchr.c>
-#endif
diff --git a/sysdeps/powerpc/powerpc64/power6/wcsrchr.c b/sysdeps/powerpc/powerpc64/power6/wcsrchr.c
deleted file mode 100644
index b86472d7bd..0000000000
--- a/sysdeps/powerpc/powerpc64/power6/wcsrchr.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/powerpc/power6/wcsrchr.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/6] powerpc: Use generic wcscpy optimization
  2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
@ 2019-03-23 14:56   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 14:56 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2348 bytes --]

Hi, Adhemerval,

Thanks for doing this.

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> This patch removes the power6 wcscpy optimization and use generic
> implementation instead.  Currently both power6 and power7 ifunc variant
> resulting binary are essentially the same and the generic implementation
> with unrolling loop set to 8 also results in similar performance.

I checked the performance impact of this patch set and compared it
against the impact of the previous version [1], all on a POWER9 machine.
In the attachment, there are 6 spreadsheets (two for each of the
functions being replaced: one that shows the performance degradation
caused by the first version of this change, and another that shows that
the performance change of this new version is quite allright).  In each
of the spreadsheets, I plotted a graph that visually shows the impact on
performance.

The patch looks good to me with the ChangeLog fixed (see below).

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

[1] https://sourceware.org/ml/libc-alpha/2019-03/msg00065.html

> 	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcscpy.c):
> 	New rule.
> 	* sysdeps/powerpc/power6/wcscpy.c: Remove file.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

This file has not been removed, maybe you could just move it...

> 	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcscpy.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/power6/wcscpy.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
> 	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcscpy-power6 and
> 	wcscpy-power7.
> 	(CFLAGS-wcscpy-power7.c, CFLAGS-wcscpy-power6.c): Remove rule.
> 	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
> 	Remove wcscpy optimizations.

... Here.

[-- Attachment #2: wcsxxx.ods --]
[-- Type: application/vnd.oasis.opendocument.spreadsheet, Size: 517836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option
  2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2019-03-13 14:03 ` [PATCH v2 6/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
@ 2019-03-23 15:00 ` Gabriel F. T. Gomes
  5 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 15:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> This allows an architecture the use the old generic implementation
> and also set explicit loop unrolling.

s/the use/to use/

> 	* include/loop_unroll.h: New file.
> 	* wcsmbs/wcscpy (__wcscpy): Add option to use loop unrolling
> 	besides generic implementation.

OK.

> +/* Loop unroll macro to be used for explicity force loop unrolling with a
> +   configurable number or iterations.  The idea is to make the loop unrolling
> +   independent of whether compiler is able to unrolling through specific
> +   optimizations options (-funroll-loops or -funroll-all-loops).
> +
> +   For instance, to implement strcpy with SRC being the source input and 
> +   DEST the destination buffer, it is expected the macro to be used in this
> +   way:
> +
> +     #define ITERATION(index)	\
> +       ({ char c = *str++; *dest++ = c; c != '\0' })
> +
> +     while (1)
> +       UNROLL_REPEAT (4, ITERATION)
> +
> +   The loop will be manually unrolled 4 times.  Another option is to do
> +   the index update after the tests:
> +
> +     #define ITERATION(index)	\
> +       ({ char c = *(str + index); *(dest + index) = c; c != '\0' })
> +     #define UPDATE(n)		\
> +       str += n; dst += n
> +
> +     while (1)
> +       UNROLL_REPEAT_UPDATE (4, ITERATION, UPDATE)
> +
> +   The loop will be manually unrolled 4 times and the SRC and DEST pointers
> +   will be update only after last iteration.
> +
> +   Currently both macros unrolls the loop 8 times at maximum.  */

Thanks for writing this detailed explanation.

> +#define UNROLL_REPEAT_1(X)    if (!X(0)) break;
> +#define UNROLL_REPEAT_2(X)    UNROLL_REPEAT_1(X) if (!X(1)) break;
> +#define UNROLL_REPEAT_3(X)    UNROLL_REPEAT_2(X) if (!X(2)) break;
> +#define UNROLL_REPEAT_4(X)    UNROLL_REPEAT_3(X) if (!X(3)) break;
> +#define UNROLL_REPEAT_5(X)    UNROLL_REPEAT_4(X) if (!X(4)) break;
> +#define UNROLL_REPEAT_6(X)    UNROLL_REPEAT_5(X) if (!X(5)) break;
> +#define UNROLL_REPEAT_7(X)    UNROLL_REPEAT_6(X) if (!X(6)) break;
> +#define UNROLL_REPEAT_8(X)    UNROLL_REPEAT_7(X) if (!X(7)) break;
                                                ^         ^
Missing space between macro call and parentheses (twice in each line).

> +#define UNROLL_REPEAT__(N, X) UNROLL_EXPAND(UNROLL_REPEAT_ ## N) (X)
                                              ^
I think that this is OK according to the style guidelines, as it just
expands the name to UNROLL_REPEAT_1, UNROLL_REPEAT_2, etc.  But maybe I
just didn't quite understand the guidelines.

> +#define UNROLL_REPEAT(N, X)                \
> +  (void) ({                                \
> +    UNROLL_REPEAT_(UNROLL_EXPAND(N), X);   \
                     ^
Missing space.

> +  /* Some architectures might have costly tail function call (powerpc
> +     for instance) where wmemcpy call overhead for smalls sizes might
> +     be costly than just unroll the main loop.  */

s/be costly than just unroll/be more costly than just unrolling/

... I think.

Looks good to me with these changes.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr
  2019-03-13 14:03 ` [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr Adhemerval Zanella
@ 2019-03-23 15:00   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 15:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> 
> 	* wcsmbs/wcschr.c (WCSCHR): Use loop_unroll.h to parametrize
> 	the loop unroll.

Looks good to me with a minor fix below.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> +  while (1)
> +    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
                    ^
Missing space between macro name and parentheses?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 4/6] powerpc: Use generic wcschr optimization
  2019-03-13 14:03 ` [PATCH v2 4/6] powerpc: Use generic wcschr optimization Adhemerval Zanella
@ 2019-03-23 15:00   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 15:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> This patch removes the power6 wcschr optimization and use generic
> implementation instead.  Currently both power6 and power7 ifunc variant
> resulting binary are essentially the same and the generic implementation
> with unrolling loop set to 8 also results in similar performance.

The patch looks good to me with the ChangeLog fixed (see below).

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> 	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
> 	New rule.
> 	* sysdeps/powerpc/power6/wcschr.c: Remove file.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

This file has not been removed, maybe you could just move it...

> 	* sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcschr.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/power6/wcschr.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
> 	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcschr-power6 and
> 	wcschr-power7.
> 	(CFLAGS-wcschr-power7.c, CFLAGS-wcschr-power6.c): Remove rule.
> 	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
> 	Remove wcschr optimizations.

... Here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr
  2019-03-13 14:03 ` [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr Adhemerval Zanella
@ 2019-03-23 15:00   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 15:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> 
> 	* wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize
> 	the loop unroll.

Looks good to me with a minor fix below.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> +  while (1)
> +    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
                    ^
Missing space between macro name and parentheses?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 6/6] powerpc: Use generic wcscpy optimization
  2019-03-13 14:03 ` [PATCH v2 6/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
@ 2019-03-23 15:01   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel F. T. Gomes @ 2019-03-23 15:01 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

> [PATCH v2 6/6] powerpc: Use generic wcscpy optimization

In the commit headline, replace wcscpy with wcsrchr.

On Wed, Mar 13 2019, Adhemerval Zanella wrote:
> This patch removes the power6 wcsrchr optimization and use generic
> implementation instead.  Currently both power6 and power7 ifunc variant
> resulting binary are essentially the same and the generic implementation
> with unrolling loop set to 8 also results in similar performance.

The patch looks good to me with the commit headline (see above) and
ChangeLog (see below) fixed.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

> 	* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
> 	New rule.

s/wcschr/wcsrchr/

> 	* sysdeps/powerpc/power6/wcsrchr.c: Remove file.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c:
> 	Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

This file has not been removed, maybe you could just move it...

> 	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c: Likewise.
> 	* sysdeps/powerpc/powerpc64/power6/wcsrchr.c: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
> 	[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcsrchr-power6 and
> 	wcsrchr-power7.
> 	(CFLAGS-wcsrchr-power7.c, CFLAGS-wcsrchr-power6.c): Remove rule.
> 	* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
> 	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
> 	Remove wcsrchr optimizations.

... Here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-03-23 15:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
2019-03-23 14:56   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr Adhemerval Zanella
2019-03-23 15:00   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 4/6] powerpc: Use generic wcschr optimization Adhemerval Zanella
2019-03-23 15:00   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr Adhemerval Zanella
2019-03-23 15:00   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 6/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
2019-03-23 15:01   ` Gabriel F. T. Gomes
2019-03-23 15:00 ` [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Gabriel F. T. Gomes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).