[v2] More string benchtest cleanups

Message ID DB5PR08MB10302CEA8DF72A622AEA499A83680@DB5PR08MB1030.eurprd08.prod.outlook.com
State New
Headers show
Series
  • [v2] More string benchtest cleanups
Related show

Commit Message

Wilco Dijkstra Feb. 7, 2019, 5:19 p.m.
v2: Remove the "stupid" and "builtin" implementations too.

Continue cleanup of the string benchtests.  Remove simplistic
byte-oriented versions with faster generic implementations.
Remove bcopy/bzero benchmarks (bcopy/bzero are obsolete and never
emitted by compilers).  Remove builtin versions of memcpy, memset
and strlen.  Remove all remaining "stupid" implementations given
they are always slower than the "simple" variants and thus don't
add anything useful.

OK for commit?

2019-02-07  Wilco Dijkstra  <wdijkstr@arm.com>

	* benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove.
	* benchtests/bench-strcasestr.c (stupid_strcasestr): Remove.
	* benchtests/bench-strchr.c (stupid_strchr): Remove.
	* benchtests/bench-strcmp.c (stupid_strcmp): Remove.
	* benchtests/bench-strcspn.c (stupid_strcspn): Remove.
	* benchtests/bench-strlen.c (builtin_strlen): Remove.
	* benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove.
	* benchtests/bench-strncmp.c (stupid_strncmp): Remove.
	* benchtests/bench-strpbrk.c (stupid_strpbrk): Remove.
	* benchtests/bench-strspn.c (stupid_strspn): Remove.
	* benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c.
	* benchtests/bench-bcopy.c: Delete file.
	* benchtests/bench-bzero.c: Likewise.
	* benchtests/bench-memccpy.c (stupid_memccpy): Remove.
	(simple_memccpy): Remove.
	(generic_memccpy): Add function.
	* benchtests/bench-memcpy.c: (builtin_memcpy): Remove.
	* benchtests/bench-memmove.c (simple_bcopy): Remove.
	* benchtests/bench-mempcpy.c (simple_mempcpy): Remove.
	(generic_mempcpy): Add new function.
	* benchtests/bench-memset.c (simple_bzero): Remove.
	(builtin_bzero): Remove.
	(builtin_memset): Remove.
	* benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove.
	(generic_rawmemchr): Add new function.

--

Comments

Adhemerval Zanella Feb. 8, 2019, 6:51 p.m. | #1
On 07/02/2019 15:19, Wilco Dijkstra wrote:
> v2: Remove the "stupid" and "builtin" implementations too.
> 
> Continue cleanup of the string benchtests.  Remove simplistic
> byte-oriented versions with faster generic implementations.
> Remove bcopy/bzero benchmarks (bcopy/bzero are obsolete and never
> emitted by compilers).  Remove builtin versions of memcpy, memset
> and strlen.  Remove all remaining "stupid" implementations given
> they are always slower than the "simple" variants and thus don't
> add anything useful.
> 
> OK for commit?
> 
> 2019-02-07  Wilco Dijkstra  <wdijkstr@arm.com>
> 
> 	* benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove.
> 	* benchtests/bench-strcasestr.c (stupid_strcasestr): Remove.
> 	* benchtests/bench-strchr.c (stupid_strchr): Remove.
> 	* benchtests/bench-strcmp.c (stupid_strcmp): Remove.
> 	* benchtests/bench-strcspn.c (stupid_strcspn): Remove.
> 	* benchtests/bench-strlen.c (builtin_strlen): Remove.
> 	* benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove.
> 	* benchtests/bench-strncmp.c (stupid_strncmp): Remove.
> 	* benchtests/bench-strpbrk.c (stupid_strpbrk): Remove.
> 	* benchtests/bench-strspn.c (stupid_strspn): Remove.
> 	* benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c.
> 	* benchtests/bench-bcopy.c: Delete file.
> 	* benchtests/bench-bzero.c: Likewise.
> 	* benchtests/bench-memccpy.c (stupid_memccpy): Remove.
> 	(simple_memccpy): Remove.
> 	(generic_memccpy): Add function.
> 	* benchtests/bench-memcpy.c: (builtin_memcpy): Remove.
> 	* benchtests/bench-memmove.c (simple_bcopy): Remove.
> 	* benchtests/bench-mempcpy.c (simple_mempcpy): Remove.
> 	(generic_mempcpy): Add new function.
> 	* benchtests/bench-memset.c (simple_bzero): Remove.
> 	(builtin_bzero): Remove.
> 	(builtin_memset): Remove.
> 	* benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove.
> 	(generic_rawmemchr): Add new function.

LGTM, thanks.

> 
> --
> diff --git a/benchtests/Makefile b/benchtests/Makefile
> index e1907753b4e4cd7de49d072385f35e3dd84fa3ca..3339f2c770e67b7d6b848820971fcee607128b83 100644
> --- a/benchtests/Makefile
> +++ b/benchtests/Makefile
> @@ -37,7 +37,7 @@ bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
>  endif
>  
>  # String function benchmarks.
> -string-benchset := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
> +string-benchset := memccpy memchr memcmp memcpy memmem memmove \
>  		   mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
>  		   strcat strchr strchrnul strcmp strcpy strcspn strlen \
>  		   strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
> diff --git a/benchtests/bench-bcopy.c b/benchtests/bench-bcopy.c
> deleted file mode 100644
> index f8f33cb7f5db9e81880845c229fb5e0a82c790de..0000000000000000000000000000000000000000
> --- a/benchtests/bench-bcopy.c
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -/* Measure bcopy functions.
> -   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 TEST_BCOPY
> -#include "bench-memmove.c"

Ok.

> diff --git a/benchtests/bench-bzero.c b/benchtests/bench-bzero.c
> deleted file mode 100644
> index 36f884a7fd74b8a1a1ad908cb30d5cda1168e536..0000000000000000000000000000000000000000
> --- a/benchtests/bench-bzero.c
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -/* Measure bzero functions.
> -   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 TEST_BZERO
> -#include "bench-memset.c"

Ok.

> diff --git a/benchtests/bench-memccpy.c b/benchtests/bench-memccpy.c
> index 6dca16be24b234bd886b01b36dc9a66662b62ca2..d3a2df5e72b4ae0bba68c2e94f33d8255d04fcb3 100644
> --- a/benchtests/bench-memccpy.c
> +++ b/benchtests/bench-memccpy.c
> @@ -20,28 +20,8 @@
>  #define TEST_NAME "memccpy"
>  #include "bench-string.h"
>  
> -void *simple_memccpy (void *, const void *, int, size_t);
> -void *stupid_memccpy (void *, const void *, int, size_t);
> -
> -IMPL (stupid_memccpy, 0)
> -IMPL (simple_memccpy, 0)
> -IMPL (memccpy, 1)
> -
> -void *
> -simple_memccpy (void *dst, const void *src, int c, size_t n)
> -{
> -  const char *s = src;
> -  char *d = dst;
> -
> -  while (n-- > 0)
> -    if ((*d++ = *s++) == (char) c)
> -      return d;
> -
> -  return NULL;
> -}
> -
>  void *
> -stupid_memccpy (void *dst, const void *src, int c, size_t n)
> +generic_memccpy (void *dst, const void *src, int c, size_t n)
>  {
>    void *p = memchr (src, c, n);
>  
> @@ -52,6 +32,9 @@ stupid_memccpy (void *dst, const void *src, int c, size_t n)
>    return NULL;
>  }
>  
> +IMPL (memccpy, 1)
> +IMPL (generic_memccpy, 0)
> +
>  typedef void *(*proto_t) (void *, const void *, int c, size_t);
>  
>  static void

Ok.

> diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
> index b32ca4c44364f94a403389b39f7b71dc60a00d24..6c5c549144417b1845c4f9fedffc329d44fdfa6c 100644
> --- a/benchtests/bench-memcpy.c
> +++ b/benchtests/bench-memcpy.c
> @@ -23,13 +23,6 @@
>  # define TEST_NAME "memcpy"
>  # include "bench-string.h"
>  
> -char *simple_memcpy (char *, const char *, size_t);
> -char *builtin_memcpy (char *, const char *, size_t);
> -
> -IMPL (simple_memcpy, 0)
> -IMPL (builtin_memcpy, 0)
> -IMPL (memcpy, 1)
> -
>  char *
>  simple_memcpy (char *dst, const char *src, size_t n)
>  {
> @@ -39,11 +32,9 @@ simple_memcpy (char *dst, const char *src, size_t n)
>    return ret;
>  }
>  
> -char *
> -builtin_memcpy (char *dst, const char *src, size_t n)
> -{
> -  return __builtin_memcpy (dst, src, n);
> -}
> +IMPL (memcpy, 1)
> +IMPL (simple_memcpy, 0)
> +
>  #endif
>  
>  # include "json-lib.h"

Ok.

> diff --git a/benchtests/bench-memmove.c b/benchtests/bench-memmove.c
> index ad1f0bb767c921341b3d802695538cd405714fc3..a5d957791a780762bf4904fee2b84bd9be6a8dcd 100644
> --- a/benchtests/bench-memmove.c
> +++ b/benchtests/bench-memmove.c
> @@ -17,34 +17,16 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #define TEST_MAIN
> -#ifdef TEST_BCOPY
> -# define TEST_NAME "bcopy"
> -#else
> -# define TEST_NAME "memmove"
> -#endif
> +#define TEST_NAME "memmove"
>  #include "bench-string.h"
>  #include "json-lib.h"
>  
>  char *simple_memmove (char *, const char *, size_t);
>  
> -#ifdef TEST_BCOPY
> -typedef void (*proto_t) (const char *, char *, size_t);
> -void simple_bcopy (const char *, char *, size_t);
> -
> -IMPL (simple_bcopy, 0)
> -IMPL (bcopy, 1)
> -
> -void
> -simple_bcopy (const char *src, char *dst, size_t n)
> -{
> -  simple_memmove (dst, src, n);
> -}
> -#else
>  typedef char *(*proto_t) (char *, const char *, size_t);
>  
> -IMPL (simple_memmove, 0)
>  IMPL (memmove, 1)
> -#endif
> +IMPL (simple_memmove, 0)
>  
>  char *
>  inhibit_loop_to_libcall
> @@ -74,11 +56,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, const
>    TIMING_NOW (start);
>    for (i = 0; i < iters; ++i)
>      {
> -#ifdef TEST_BCOPY
> -      CALL (impl, src, dst, len);
> -#else
>        CALL (impl, dst, src, len);
> -#endif
>      }
>    TIMING_NOW (stop);
>  

Ok.

> diff --git a/benchtests/bench-mempcpy.c b/benchtests/bench-mempcpy.c
> index 82b276b8232cd140fb1603f9ab8ede27f30e72f8..09f8557413f92d95d25c6396e74e9a3bc14d73ff 100644
> --- a/benchtests/bench-mempcpy.c
> +++ b/benchtests/bench-mempcpy.c
> @@ -21,17 +21,13 @@
>  #define TEST_NAME "mempcpy"
>  #include "bench-string.h"
>  
> -char *simple_mempcpy (char *, const char *, size_t);
> -
> -IMPL (simple_mempcpy, 0)
> -IMPL (mempcpy, 1)
> -
>  char *
> -simple_mempcpy (char *dst, const char *src, size_t n)
> +generic_mempcpy (char *dst, const char *src, size_t n)
>  {
> -  while (n--)
> -    *dst++ = *src++;
> -  return dst;
> +  return memcpy (dst, src, n) + n;
>  }
>  
> +IMPL (mempcpy, 1)
> +IMPL (generic_mempcpy, 0)
> +
>  #include "bench-memcpy.c"

Ok.

> diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
> index c2679a6ac108ed267e15947652c064e5c8cd5a2f..0df55d126352d0db20681944e73241fef4483a80 100644
> --- a/benchtests/bench-memset.c
> +++ b/benchtests/bench-memset.c
> @@ -17,66 +17,22 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #define TEST_MAIN
> -#ifdef TEST_BZERO
> -# define TEST_NAME "bzero"
> -#else
> -# ifndef WIDE
> -#  define TEST_NAME "memset"
> -# else
> -#  define TEST_NAME "wmemset"
> -# endif /* WIDE */
> -#endif /* !TEST_BZERO */
> -#define MIN_PAGE_SIZE 131072
> -#include "bench-string.h"
> -
>  #ifndef WIDE
> -# define SIMPLE_MEMSET simple_memset
> +# define TEST_NAME "memset"
>  #else
> -# define SIMPLE_MEMSET simple_wmemset
> +# define TEST_NAME "wmemset"
>  #endif /* WIDE */
> +#define MIN_PAGE_SIZE 131072
> +#include "bench-string.h"
>  
>  #include "json-lib.h"
>  
>  CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
>  
> -#ifdef TEST_BZERO
> -typedef void (*proto_t) (char *, size_t);
> -void simple_bzero (char *, size_t);
> -void builtin_bzero (char *, size_t);
> -
> -IMPL (simple_bzero, 0)
> -IMPL (builtin_bzero, 0)
> -IMPL (bzero, 1)
> -
> -void
> -simple_bzero (char *s, size_t n)
> -{
> -  SIMPLE_MEMSET (s, 0, n);
> -}
> -
> -void
> -builtin_bzero (char *s, size_t n)
> -{
> -  __builtin_bzero (s, n);
> -}
> -#else
>  typedef CHAR *(*proto_t) (CHAR *, int, size_t);
>  
> -IMPL (SIMPLE_MEMSET, 0)
> -# ifndef WIDE
> -char *builtin_memset (char *, int, size_t);
> -IMPL (builtin_memset, 0)
> -# endif /* !WIDE */
>  IMPL (MEMSET, 1)
> -
> -# ifndef WIDE
> -char *
> -builtin_memset (char *s, int c, size_t n)
> -{
> -  return __builtin_memset (s, c, n);
> -}
> -# endif /* !WIDE */
> -#endif /* !TEST_BZERO */
> +IMPL (SIMPLE_MEMSET, 0)
>  
>  CHAR *
>  inhibit_loop_to_libcall
> @@ -98,11 +54,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
>    TIMING_NOW (start);
>    for (i = 0; i < iters; ++i)
>      {
> -#ifdef TEST_BZERO
> -      CALL (impl, s, n);
> -#else
>        CALL (impl, s, c, n);
> -#endif /* !TEST_BZERO */
>      }
>    TIMING_NOW (stop);
>  
> @@ -159,9 +111,7 @@ test_main (void)
>  
>    json_array_begin (&json_ctx, "results");
>  
> -#ifndef TEST_BZERO
>    for (c = -65; c <= 130; c += 65)
> -#endif
>      {
>        for (i = 0; i < 18; ++i)
>  	do_test (&json_ctx, 0, c, 1 << i);

Ok.

> diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
> index 2b11cfe4833f3a707b70c7ca3b282c239d484338..44f3114fd2338db20e0d503ef08f5032d0de8157 100644
> --- a/benchtests/bench-rawmemchr.c
> +++ b/benchtests/bench-rawmemchr.c
> @@ -17,26 +17,25 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #include <assert.h>
> +#include <stdint.h>
>  
>  #define TEST_MAIN
>  #define TEST_NAME "rawmemchr"
>  #include "bench-string.h"
>  
>  typedef char *(*proto_t) (const char *, int);
> -char *simple_rawmemchr (const char *, int);
> -
> -IMPL (simple_rawmemchr, 0)
> -IMPL (rawmemchr, 1)
>  
>  char *
> -simple_rawmemchr (const char *s, int c)
> +generic_rawmemchr (const char *s, int c)
>  {
> -  while (1)
> -    if (*s++ == (char) c)
> -      return (char *) s - 1;
> -  return NULL;
> +  if (c != 0)
> +    return memchr (s, c, PTRDIFF_MAX);
> +  return (char *)s + strlen (s);
>  }
>  
> +IMPL (rawmemchr, 1)
> +IMPL (generic_rawmemchr, 0)
> +
>  static void
>  do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
>  {

Ok.

> diff --git a/benchtests/bench-strcasecmp.c b/benchtests/bench-strcasecmp.c
> index 5c471a8678c583e60d1dc34aa24618c9532e8c80..4e9bcdc9a58c0ea6f622148bbf5e700558feaf2d 100644
> --- a/benchtests/bench-strcasecmp.c
> +++ b/benchtests/bench-strcasecmp.c
> @@ -23,9 +23,7 @@
>  
>  typedef int (*proto_t) (const char *, const char *);
>  static int simple_strcasecmp (const char *, const char *);
> -static int stupid_strcasecmp (const char *, const char *);
>  
> -IMPL (stupid_strcasecmp, 0)
>  IMPL (simple_strcasecmp, 0)
>  IMPL (strcasecmp, 1)
>  
> @@ -41,24 +39,6 @@ simple_strcasecmp (const char *s1, const char *s2)
>    return ret;
>  }
>  
> -static int
> -stupid_strcasecmp (const char *s1, const char *s2)
> -{
> -  size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1;
> -  size_t n = ns1 < ns2 ? ns1 : ns2;
> -  int ret = 0;
> -
> -  while (n--)
> -    {
> -      if ((ret = ((unsigned char) tolower (*s1)
> -		  - (unsigned char) tolower (*s2))) != 0)
> -	break;
> -      ++s1;
> -      ++s2;
> -    }
> -  return ret;
> -}
> -
>  static void
>  do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result)
>  {

Ok.

> diff --git a/benchtests/bench-strcasestr.c b/benchtests/bench-strcasestr.c
> index 030e5c76016d150d265e90051a7101fc73762e1e..1458070d47cbfe5e27d40288f8ac7f83df735d08 100644
> --- a/benchtests/bench-strcasestr.c
> +++ b/benchtests/bench-strcasestr.c
> @@ -27,33 +27,8 @@
>  #define __strnlen strnlen
>  #include "../string/strcasestr.c"
>  
> -
> -static char *
> -stupid_strcasestr (const char *s1, const char *s2)
> -{
> -  ssize_t s1len = strlen (s1);
> -  ssize_t s2len = strlen (s2);
> -
> -  if (s2len > s1len)
> -    return NULL;
> -
> -  for (ssize_t i = 0; i <= s1len - s2len; ++i)
> -    {
> -      size_t j;
> -      for (j = 0; j < s2len; ++j)
> -	if (tolower (s1[i + j]) != tolower (s2[j]))
> -	  break;
> -      if (j == s2len)
> -	return (char *) s1 + i;
> -    }
> -
> -  return NULL;
> -}
> -
> -
>  typedef char *(*proto_t) (const char *, const char *);
>  
> -IMPL (stupid_strcasestr, 0)
>  IMPL (simple_strcasestr, 0)
>  IMPL (strcasestr, 1)
>  

Ok.

> diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
> index 0648c99f370184f704ffd6147a735998aac742fd..b8dba17caed2baac7229f442389be7924db4c44d 100644
> --- a/benchtests/bench-strchr.c
> +++ b/benchtests/bench-strchr.c
> @@ -38,7 +38,6 @@
>  # ifdef USE_FOR_STRCHRNUL
>  #  undef STRCHR
>  #  define STRCHR strchrnul
> -#  define stupid_STRCHR stupid_STRCHRNUL
>  #  define simple_STRCHR simple_STRCHRNUL
>  # endif /* !USE_FOR_STRCHRNUL */
>  # define MIDDLE_CHAR 127
> @@ -47,7 +46,6 @@
>  # ifdef USE_FOR_STRCHRNUL
>  #  undef STRCHR
>  #  define STRCHR wcschrnul
> -#  define stupid_STRCHR stupid_WCSCHRNUL
>  #  define simple_STRCHR simple_WCSCHRNUL
>  # endif /* !USE_FOR_STRCHRNUL */
>  # define MIDDLE_CHAR 1121
> @@ -72,18 +70,6 @@ simple_STRCHR (const CHAR *s, int c)
>    return (CHAR *) s;
>  }
>  
> -CHAR *
> -stupid_STRCHR (const CHAR *s, int c)
> -{
> -  size_t n = STRLEN (s) + 1;
> -
> -  while (n--)
> -    if (*s++ == (CHAR) c)
> -      return (CHAR *) s - 1;
> -  return NULLRET ((CHAR *) s - 1);
> -}
> -
> -IMPL (stupid_STRCHR, 0)
>  IMPL (simple_STRCHR, 0)
>  IMPL (STRCHR, 1)
>  

Ok.

> diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c
> index 695aa19f929906ec9c194fdb7d2fb0cf83258151..c87b3ac02bda1c35ee604dfa0551a0fa1934cb75 100644
> --- a/benchtests/bench-strcmp.c
> +++ b/benchtests/bench-strcmp.c
> @@ -27,7 +27,6 @@
>  #ifdef WIDE
>  # define L(str) L##str
>  # define SIMPLE_STRCMP simple_wcscmp
> -# define STUPID_STRCMP stupid_wcscmp
>  # define CHARBYTESLOG 2
>  # define MIDCHAR 0x7fffffff
>  # define LARGECHAR 0xfffffffe
> @@ -51,31 +50,11 @@ simple_wcscmp (const wchar_t *s1, const wchar_t *s2)
>    return c1 < c2 ? -1 : 1;
>  }
>  
> -int
> -stupid_wcscmp (const wchar_t *s1, const wchar_t *s2)
> -{
> -  size_t ns1 = wcslen (s1) + 1;
> -  size_t ns2 = wcslen (s2) + 1;
> -  size_t n = ns1 < ns2 ? ns1 : ns2;
> -  int ret = 0;
> -
> -  wchar_t c1, c2;
> -
> -  while (n--) {
> -    c1 = *s1++;
> -    c2 = *s2++;
> -    if ((ret = c1 < c2 ? -1 : c1 == c2 ? 0 : 1) != 0)
> -      break;
> -  }
> -  return ret;
> -}
> -
>  #else
>  # include <limits.h>
>  
>  # define L(str) str
>  # define SIMPLE_STRCMP simple_strcmp
> -# define STUPID_STRCMP stupid_strcmp
>  # define CHARBYTESLOG 0
>  # define MIDCHAR 0x7f
>  # define LARGECHAR 0xfe
> @@ -90,26 +69,12 @@ simple_strcmp (const char *s1, const char *s2)
>    return ret;
>  }
>  
> -int
> -stupid_strcmp (const char *s1, const char *s2)
> -{
> -  size_t ns1 = strlen (s1) + 1;
> -  size_t ns2 = strlen (s2) + 1;
> -  size_t n = ns1 < ns2 ? ns1 : ns2;
> -  int ret = 0;
> -
> -  while (n--)
> -    if ((ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) != 0)
> -      break;
> -  return ret;
> -}
>  #endif
>  
>  # include "json-lib.h"
>  
>  typedef int (*proto_t) (const CHAR *, const CHAR *);
>  
> -IMPL (STUPID_STRCMP, 1)
>  IMPL (SIMPLE_STRCMP, 1)
>  IMPL (STRCMP, 1)
>  

Ok.

> diff --git a/benchtests/bench-strcspn.c b/benchtests/bench-strcspn.c
> index c5d723d983bdcf40c5c845f2c2cc0f1a29925325..bf9c4f8db39940d321323ca4750395efdadcaa37 100644
> --- a/benchtests/bench-strcspn.c
> +++ b/benchtests/bench-strcspn.c
> @@ -28,17 +28,13 @@
>  
>  #ifndef WIDE
>  # define SIMPLE_STRCSPN simple_strcspn
> -# define STUPID_STRCSPN stupid_strcspn
>  #else
>  # define SIMPLE_STRCSPN simple_wcscspn
> -# define STUPID_STRCSPN stupid_wcscspn
>  #endif /* WIDE */
>  
>  typedef size_t (*proto_t) (const CHAR *, const CHAR *);
>  size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
> -size_t STUPID_STRCSPN (const CHAR *, const CHAR *);
>  
> -IMPL (STUPID_STRCSPN, 0)
>  IMPL (SIMPLE_STRCSPN, 0)
>  IMPL (STRCSPN, 1)
>  
> @@ -55,17 +51,4 @@ SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
>    return s - str - 1;
>  }
>  
> -size_t
> -STUPID_STRCSPN (const CHAR *s, const CHAR *rej)
> -{
> -  size_t ns = STRLEN (s), nrej = STRLEN (rej);
> -  size_t i, j;
> -
> -  for (i = 0; i < ns; ++i)
> -    for (j = 0; j < nrej; ++j)
> -      if (s[i] == rej[j])
> -	return i;
> -  return i;
> -}
> -
>  #include "bench-strpbrk.c"

Ok.

> diff --git a/benchtests/bench-strlen.c b/benchtests/bench-strlen.c
> index b1cd2accb487293f37a5b5510e396f7310f99f6a..f86095a5d3ce1746b7c0a37d29799a8fe4c83f87 100644
> --- a/benchtests/bench-strlen.c
> +++ b/benchtests/bench-strlen.c
> @@ -34,15 +34,6 @@ size_t memchr_strlen (const CHAR *);
>  IMPL (memchr_strlen, 0)
>  IMPL (generic_strlen, 0)
>  
> -#ifndef WIDE
> -size_t
> -builtin_strlen (const CHAR *p)
> -{
> -  return __builtin_strlen (p);
> -}
> -IMPL (builtin_strlen, 0)
> -#endif
> -
>  size_t
>  memchr_strlen (const CHAR *p)
>  {

Ok.

> diff --git a/benchtests/bench-strncasecmp.c b/benchtests/bench-strncasecmp.c
> index e18302a9c4fdf04474c39d5cbaf85ef511310072..7c97877112ca2210bb54de2764a979281d67e8b7 100644
> --- a/benchtests/bench-strncasecmp.c
> +++ b/benchtests/bench-strncasecmp.c
> @@ -23,9 +23,7 @@
>  
>  typedef int (*proto_t) (const char *, const char *, size_t);
>  static int simple_strncasecmp (const char *, const char *, size_t);
> -static int stupid_strncasecmp (const char *, const char *, size_t);
>  
> -IMPL (stupid_strncasecmp, 0)
>  IMPL (simple_strncasecmp, 0)
>  IMPL (strncasecmp, 1)
>  
> @@ -48,27 +46,6 @@ simple_strncasecmp (const char *s1, const char *s2, size_t n)
>    return ret;
>  }
>  
> -static int
> -stupid_strncasecmp (const char *s1, const char *s2, size_t max)
> -{
> -  size_t ns1 = strlen (s1) + 1;
> -  size_t ns2 = strlen (s2) + 1;
> -  size_t n = ns1 < ns2 ? ns1 : ns2;
> -  if (n > max)
> -    n = max;
> -  int ret = 0;
> -
> -  while (n--)
> -    {
> -      if ((ret = ((unsigned char) tolower (*s1)
> -		  - (unsigned char) tolower (*s2))) != 0)
> -	break;
> -      ++s1;
> -      ++s2;
> -    }
> -  return ret;
> -}
> -
>  static void
>  do_one_test (impl_t *impl, const char *s1, const char *s2, size_t n,
>  	     int exp_result)

Ok.

> diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c
> index 750150c245b05171068653234daabdc4f7a6ca2b..a4f3412a8fed49fdf1813974031827fc92fdd8f3 100644
> --- a/benchtests/bench-strncmp.c
> +++ b/benchtests/bench-strncmp.c
> @@ -28,7 +28,6 @@
>  #ifdef WIDE
>  # define L(str) L##str
>  # define SIMPLE_STRNCMP simple_wcsncmp
> -# define STUPID_STRNCMP stupid_wcsncmp
>  
>  /* Wcsncmp uses signed semantics for comparison, not unsigned.
>     Avoid using substraction since possible overflow.  */
> @@ -47,29 +46,9 @@ simple_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
>    return 0;
>  }
>  
> -int
> -stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
> -{
> -  wchar_t c1, c2;
> -  size_t ns1 = wcsnlen (s1, n) + 1, ns2 = wcsnlen (s2, n) + 1;
> -
> -  n = ns1 < n ? ns1 : n;
> -  n = ns2 < n ? ns2 : n;
> -
> -  while (n--)
> -    {
> -      c1 = *s1++;
> -      c2 = *s2++;
> -      if (c1 != c2)
> -	return c1 > c2 ? 1 : -1;
> -    }
> -  return 0;
> -}
> -
>  #else
>  # define L(str) str
>  # define SIMPLE_STRNCMP simple_strncmp
> -# define STUPID_STRNCMP stupid_strncmp
>  
>  /* Strncmp uses unsigned semantics for comparison.  */
>  int
> @@ -82,23 +61,10 @@ simple_strncmp (const char *s1, const char *s2, size_t n)
>    return ret;
>  }
>  
> -int
> -stupid_strncmp (const char *s1, const char *s2, size_t n)
> -{
> -  size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1;
> -  int ret = 0;
> -
> -  n = ns1 < n ? ns1 : n;
> -  n = ns2 < n ? ns2 : n;
> -  while (n-- && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
> -  return ret;
> -}
> -
>  #endif /* !WIDE */
>  
>  typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
>  
> -IMPL (STUPID_STRNCMP, 0)
>  IMPL (SIMPLE_STRNCMP, 0)
>  IMPL (STRNCMP, 1)
>  

Ok.

> diff --git a/benchtests/bench-strpbrk.c b/benchtests/bench-strpbrk.c
> index 61639cfd5b055145b727b7e7c5dc4316a225de3d..14e1bcb873fa86caa1f50a9013f52cd422e74185 100644
> --- a/benchtests/bench-strpbrk.c
> +++ b/benchtests/bench-strpbrk.c
> @@ -37,17 +37,13 @@
>  
>  # ifndef WIDE
>  #  define SIMPLE_STRPBRK simple_strpbrk
> -#  define STUPID_STRPBRK stupid_strpbrk
>  # else
>  #  define SIMPLE_STRPBRK simple_wcspbrk
> -#  define STUPID_STRPBRK stupid_wcspbrk
>  # endif /* WIDE */
>  
>  typedef CHAR *(*proto_t) (const CHAR *, const CHAR *);
>  CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *);
> -CHAR *STUPID_STRPBRK (const CHAR *, const CHAR *);
>  
> -IMPL (STUPID_STRPBRK, 0)
>  IMPL (SIMPLE_STRPBRK, 0)
>  IMPL (STRPBRK, 1)
>  
> @@ -64,18 +60,6 @@ SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej)
>    return NULL;
>  }
>  
> -CHAR *
> -STUPID_STRPBRK (const CHAR *s, const CHAR *rej)
> -{
> -  size_t ns = STRLEN (s), nrej = STRLEN (rej);
> -  size_t i, j;
> -
> -  for (i = 0; i < ns; ++i)
> -    for (j = 0; j < nrej; ++j)
> -      if (s[i] == rej[j])
> -	return (CHAR *) s + i;
> -  return NULL;
> -}
>  #endif /* !STRPBRK_RESULT */
>  
>  static void

Ok.

> diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
> index 04507cdd61be04baec9a441baf348dcbde2928d3..ac874fe234af66ad98a6188099f32c10484452db 100644
> --- a/benchtests/bench-strspn.c
> +++ b/benchtests/bench-strspn.c
> @@ -28,19 +28,15 @@
>  
>  #ifndef WIDE
>  # define SIMPLE_STRSPN simple_strspn
> -# define STUPID_STRSPN stupid_strspn
>  # define SMALL_CHAR 127
>  #else
>  # define SIMPLE_STRSPN simple_wcsspn
> -# define STUPID_STRSPN stupid_wcsspn
>  # define SMALL_CHAR 1273
>  #endif /* WIDE */
>  
>  typedef size_t (*proto_t) (const CHAR *, const CHAR *);
>  size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
> -size_t STUPID_STRSPN (const CHAR *, const CHAR *);
>  
> -IMPL (STUPID_STRSPN, 0)
>  IMPL (SIMPLE_STRSPN, 0)
>  IMPL (STRSPN, 1)
>  
> @@ -61,23 +57,6 @@ SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
>    return s - str - 1;
>  }
>  
> -size_t
> -STUPID_STRSPN (const CHAR *s, const CHAR *acc)
> -{
> -  size_t ns = STRLEN (s), nacc = STRLEN (acc);
> -  size_t i, j;
> -
> -  for (i = 0; i < ns; ++i)
> -    {
> -      for (j = 0; j < nacc; ++j)
> -	if (s[i] == acc[j])
> -	  break;
> -      if (j == nacc)
> -	return i;
> -    }
> -  return i;
> -}
> -
>  static void
>  do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
>  {
> 

Ok.

Patch

diff --git a/benchtests/Makefile b/benchtests/Makefile
index e1907753b4e4cd7de49d072385f35e3dd84fa3ca..3339f2c770e67b7d6b848820971fcee607128b83 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -37,7 +37,7 @@  bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
 endif
 
 # String function benchmarks.
-string-benchset := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
+string-benchset := memccpy memchr memcmp memcpy memmem memmove \
 		   mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
 		   strcat strchr strchrnul strcmp strcpy strcspn strlen \
 		   strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
diff --git a/benchtests/bench-bcopy.c b/benchtests/bench-bcopy.c
deleted file mode 100644
index f8f33cb7f5db9e81880845c229fb5e0a82c790de..0000000000000000000000000000000000000000
--- a/benchtests/bench-bcopy.c
+++ /dev/null
@@ -1,20 +0,0 @@ 
-/* Measure bcopy functions.
-   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 TEST_BCOPY
-#include "bench-memmove.c"
diff --git a/benchtests/bench-bzero.c b/benchtests/bench-bzero.c
deleted file mode 100644
index 36f884a7fd74b8a1a1ad908cb30d5cda1168e536..0000000000000000000000000000000000000000
--- a/benchtests/bench-bzero.c
+++ /dev/null
@@ -1,19 +0,0 @@ 
-/* Measure bzero functions.
-   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 TEST_BZERO
-#include "bench-memset.c"
diff --git a/benchtests/bench-memccpy.c b/benchtests/bench-memccpy.c
index 6dca16be24b234bd886b01b36dc9a66662b62ca2..d3a2df5e72b4ae0bba68c2e94f33d8255d04fcb3 100644
--- a/benchtests/bench-memccpy.c
+++ b/benchtests/bench-memccpy.c
@@ -20,28 +20,8 @@ 
 #define TEST_NAME "memccpy"
 #include "bench-string.h"
 
-void *simple_memccpy (void *, const void *, int, size_t);
-void *stupid_memccpy (void *, const void *, int, size_t);
-
-IMPL (stupid_memccpy, 0)
-IMPL (simple_memccpy, 0)
-IMPL (memccpy, 1)
-
-void *
-simple_memccpy (void *dst, const void *src, int c, size_t n)
-{
-  const char *s = src;
-  char *d = dst;
-
-  while (n-- > 0)
-    if ((*d++ = *s++) == (char) c)
-      return d;
-
-  return NULL;
-}
-
 void *
-stupid_memccpy (void *dst, const void *src, int c, size_t n)
+generic_memccpy (void *dst, const void *src, int c, size_t n)
 {
   void *p = memchr (src, c, n);
 
@@ -52,6 +32,9 @@  stupid_memccpy (void *dst, const void *src, int c, size_t n)
   return NULL;
 }
 
+IMPL (memccpy, 1)
+IMPL (generic_memccpy, 0)
+
 typedef void *(*proto_t) (void *, const void *, int c, size_t);
 
 static void
diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
index b32ca4c44364f94a403389b39f7b71dc60a00d24..6c5c549144417b1845c4f9fedffc329d44fdfa6c 100644
--- a/benchtests/bench-memcpy.c
+++ b/benchtests/bench-memcpy.c
@@ -23,13 +23,6 @@ 
 # define TEST_NAME "memcpy"
 # include "bench-string.h"
 
-char *simple_memcpy (char *, const char *, size_t);
-char *builtin_memcpy (char *, const char *, size_t);
-
-IMPL (simple_memcpy, 0)
-IMPL (builtin_memcpy, 0)
-IMPL (memcpy, 1)
-
 char *
 simple_memcpy (char *dst, const char *src, size_t n)
 {
@@ -39,11 +32,9 @@  simple_memcpy (char *dst, const char *src, size_t n)
   return ret;
 }
 
-char *
-builtin_memcpy (char *dst, const char *src, size_t n)
-{
-  return __builtin_memcpy (dst, src, n);
-}
+IMPL (memcpy, 1)
+IMPL (simple_memcpy, 0)
+
 #endif
 
 # include "json-lib.h"
diff --git a/benchtests/bench-memmove.c b/benchtests/bench-memmove.c
index ad1f0bb767c921341b3d802695538cd405714fc3..a5d957791a780762bf4904fee2b84bd9be6a8dcd 100644
--- a/benchtests/bench-memmove.c
+++ b/benchtests/bench-memmove.c
@@ -17,34 +17,16 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #define TEST_MAIN
-#ifdef TEST_BCOPY
-# define TEST_NAME "bcopy"
-#else
-# define TEST_NAME "memmove"
-#endif
+#define TEST_NAME "memmove"
 #include "bench-string.h"
 #include "json-lib.h"
 
 char *simple_memmove (char *, const char *, size_t);
 
-#ifdef TEST_BCOPY
-typedef void (*proto_t) (const char *, char *, size_t);
-void simple_bcopy (const char *, char *, size_t);
-
-IMPL (simple_bcopy, 0)
-IMPL (bcopy, 1)
-
-void
-simple_bcopy (const char *src, char *dst, size_t n)
-{
-  simple_memmove (dst, src, n);
-}
-#else
 typedef char *(*proto_t) (char *, const char *, size_t);
 
-IMPL (simple_memmove, 0)
 IMPL (memmove, 1)
-#endif
+IMPL (simple_memmove, 0)
 
 char *
 inhibit_loop_to_libcall
@@ -74,11 +56,7 @@  do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, const
   TIMING_NOW (start);
   for (i = 0; i < iters; ++i)
     {
-#ifdef TEST_BCOPY
-      CALL (impl, src, dst, len);
-#else
       CALL (impl, dst, src, len);
-#endif
     }
   TIMING_NOW (stop);
 
diff --git a/benchtests/bench-mempcpy.c b/benchtests/bench-mempcpy.c
index 82b276b8232cd140fb1603f9ab8ede27f30e72f8..09f8557413f92d95d25c6396e74e9a3bc14d73ff 100644
--- a/benchtests/bench-mempcpy.c
+++ b/benchtests/bench-mempcpy.c
@@ -21,17 +21,13 @@ 
 #define TEST_NAME "mempcpy"
 #include "bench-string.h"
 
-char *simple_mempcpy (char *, const char *, size_t);
-
-IMPL (simple_mempcpy, 0)
-IMPL (mempcpy, 1)
-
 char *
-simple_mempcpy (char *dst, const char *src, size_t n)
+generic_mempcpy (char *dst, const char *src, size_t n)
 {
-  while (n--)
-    *dst++ = *src++;
-  return dst;
+  return memcpy (dst, src, n) + n;
 }
 
+IMPL (mempcpy, 1)
+IMPL (generic_mempcpy, 0)
+
 #include "bench-memcpy.c"
diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
index c2679a6ac108ed267e15947652c064e5c8cd5a2f..0df55d126352d0db20681944e73241fef4483a80 100644
--- a/benchtests/bench-memset.c
+++ b/benchtests/bench-memset.c
@@ -17,66 +17,22 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #define TEST_MAIN
-#ifdef TEST_BZERO
-# define TEST_NAME "bzero"
-#else
-# ifndef WIDE
-#  define TEST_NAME "memset"
-# else
-#  define TEST_NAME "wmemset"
-# endif /* WIDE */
-#endif /* !TEST_BZERO */
-#define MIN_PAGE_SIZE 131072
-#include "bench-string.h"
-
 #ifndef WIDE
-# define SIMPLE_MEMSET simple_memset
+# define TEST_NAME "memset"
 #else
-# define SIMPLE_MEMSET simple_wmemset
+# define TEST_NAME "wmemset"
 #endif /* WIDE */
+#define MIN_PAGE_SIZE 131072
+#include "bench-string.h"
 
 #include "json-lib.h"
 
 CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
 
-#ifdef TEST_BZERO
-typedef void (*proto_t) (char *, size_t);
-void simple_bzero (char *, size_t);
-void builtin_bzero (char *, size_t);
-
-IMPL (simple_bzero, 0)
-IMPL (builtin_bzero, 0)
-IMPL (bzero, 1)
-
-void
-simple_bzero (char *s, size_t n)
-{
-  SIMPLE_MEMSET (s, 0, n);
-}
-
-void
-builtin_bzero (char *s, size_t n)
-{
-  __builtin_bzero (s, n);
-}
-#else
 typedef CHAR *(*proto_t) (CHAR *, int, size_t);
 
-IMPL (SIMPLE_MEMSET, 0)
-# ifndef WIDE
-char *builtin_memset (char *, int, size_t);
-IMPL (builtin_memset, 0)
-# endif /* !WIDE */
 IMPL (MEMSET, 1)
-
-# ifndef WIDE
-char *
-builtin_memset (char *s, int c, size_t n)
-{
-  return __builtin_memset (s, c, n);
-}
-# endif /* !WIDE */
-#endif /* !TEST_BZERO */
+IMPL (SIMPLE_MEMSET, 0)
 
 CHAR *
 inhibit_loop_to_libcall
@@ -98,11 +54,7 @@  do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
   TIMING_NOW (start);
   for (i = 0; i < iters; ++i)
     {
-#ifdef TEST_BZERO
-      CALL (impl, s, n);
-#else
       CALL (impl, s, c, n);
-#endif /* !TEST_BZERO */
     }
   TIMING_NOW (stop);
 
@@ -159,9 +111,7 @@  test_main (void)
 
   json_array_begin (&json_ctx, "results");
 
-#ifndef TEST_BZERO
   for (c = -65; c <= 130; c += 65)
-#endif
     {
       for (i = 0; i < 18; ++i)
 	do_test (&json_ctx, 0, c, 1 << i);
diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
index 2b11cfe4833f3a707b70c7ca3b282c239d484338..44f3114fd2338db20e0d503ef08f5032d0de8157 100644
--- a/benchtests/bench-rawmemchr.c
+++ b/benchtests/bench-rawmemchr.c
@@ -17,26 +17,25 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
+#include <stdint.h>
 
 #define TEST_MAIN
 #define TEST_NAME "rawmemchr"
 #include "bench-string.h"
 
 typedef char *(*proto_t) (const char *, int);
-char *simple_rawmemchr (const char *, int);
-
-IMPL (simple_rawmemchr, 0)
-IMPL (rawmemchr, 1)
 
 char *
-simple_rawmemchr (const char *s, int c)
+generic_rawmemchr (const char *s, int c)
 {
-  while (1)
-    if (*s++ == (char) c)
-      return (char *) s - 1;
-  return NULL;
+  if (c != 0)
+    return memchr (s, c, PTRDIFF_MAX);
+  return (char *)s + strlen (s);
 }
 
+IMPL (rawmemchr, 1)
+IMPL (generic_rawmemchr, 0)
+
 static void
 do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
 {
diff --git a/benchtests/bench-strcasecmp.c b/benchtests/bench-strcasecmp.c
index 5c471a8678c583e60d1dc34aa24618c9532e8c80..4e9bcdc9a58c0ea6f622148bbf5e700558feaf2d 100644
--- a/benchtests/bench-strcasecmp.c
+++ b/benchtests/bench-strcasecmp.c
@@ -23,9 +23,7 @@ 
 
 typedef int (*proto_t) (const char *, const char *);
 static int simple_strcasecmp (const char *, const char *);
-static int stupid_strcasecmp (const char *, const char *);
 
-IMPL (stupid_strcasecmp, 0)
 IMPL (simple_strcasecmp, 0)
 IMPL (strcasecmp, 1)
 
@@ -41,24 +39,6 @@  simple_strcasecmp (const char *s1, const char *s2)
   return ret;
 }
 
-static int
-stupid_strcasecmp (const char *s1, const char *s2)
-{
-  size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1;
-  size_t n = ns1 < ns2 ? ns1 : ns2;
-  int ret = 0;
-
-  while (n--)
-    {
-      if ((ret = ((unsigned char) tolower (*s1)
-		  - (unsigned char) tolower (*s2))) != 0)
-	break;
-      ++s1;
-      ++s2;
-    }
-  return ret;
-}
-
 static void
 do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result)
 {
diff --git a/benchtests/bench-strcasestr.c b/benchtests/bench-strcasestr.c
index 030e5c76016d150d265e90051a7101fc73762e1e..1458070d47cbfe5e27d40288f8ac7f83df735d08 100644
--- a/benchtests/bench-strcasestr.c
+++ b/benchtests/bench-strcasestr.c
@@ -27,33 +27,8 @@ 
 #define __strnlen strnlen
 #include "../string/strcasestr.c"
 
-
-static char *
-stupid_strcasestr (const char *s1, const char *s2)
-{
-  ssize_t s1len = strlen (s1);
-  ssize_t s2len = strlen (s2);
-
-  if (s2len > s1len)
-    return NULL;
-
-  for (ssize_t i = 0; i <= s1len - s2len; ++i)
-    {
-      size_t j;
-      for (j = 0; j < s2len; ++j)
-	if (tolower (s1[i + j]) != tolower (s2[j]))
-	  break;
-      if (j == s2len)
-	return (char *) s1 + i;
-    }
-
-  return NULL;
-}
-
-
 typedef char *(*proto_t) (const char *, const char *);
 
-IMPL (stupid_strcasestr, 0)
 IMPL (simple_strcasestr, 0)
 IMPL (strcasestr, 1)
 
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 0648c99f370184f704ffd6147a735998aac742fd..b8dba17caed2baac7229f442389be7924db4c44d 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -38,7 +38,6 @@ 
 # ifdef USE_FOR_STRCHRNUL
 #  undef STRCHR
 #  define STRCHR strchrnul
-#  define stupid_STRCHR stupid_STRCHRNUL
 #  define simple_STRCHR simple_STRCHRNUL
 # endif /* !USE_FOR_STRCHRNUL */
 # define MIDDLE_CHAR 127
@@ -47,7 +46,6 @@ 
 # ifdef USE_FOR_STRCHRNUL
 #  undef STRCHR
 #  define STRCHR wcschrnul
-#  define stupid_STRCHR stupid_WCSCHRNUL
 #  define simple_STRCHR simple_WCSCHRNUL
 # endif /* !USE_FOR_STRCHRNUL */
 # define MIDDLE_CHAR 1121
@@ -72,18 +70,6 @@  simple_STRCHR (const CHAR *s, int c)
   return (CHAR *) s;
 }
 
-CHAR *
-stupid_STRCHR (const CHAR *s, int c)
-{
-  size_t n = STRLEN (s) + 1;
-
-  while (n--)
-    if (*s++ == (CHAR) c)
-      return (CHAR *) s - 1;
-  return NULLRET ((CHAR *) s - 1);
-}
-
-IMPL (stupid_STRCHR, 0)
 IMPL (simple_STRCHR, 0)
 IMPL (STRCHR, 1)
 
diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c
index 695aa19f929906ec9c194fdb7d2fb0cf83258151..c87b3ac02bda1c35ee604dfa0551a0fa1934cb75 100644
--- a/benchtests/bench-strcmp.c
+++ b/benchtests/bench-strcmp.c
@@ -27,7 +27,6 @@ 
 #ifdef WIDE
 # define L(str) L##str
 # define SIMPLE_STRCMP simple_wcscmp
-# define STUPID_STRCMP stupid_wcscmp
 # define CHARBYTESLOG 2
 # define MIDCHAR 0x7fffffff
 # define LARGECHAR 0xfffffffe
@@ -51,31 +50,11 @@  simple_wcscmp (const wchar_t *s1, const wchar_t *s2)
   return c1 < c2 ? -1 : 1;
 }
 
-int
-stupid_wcscmp (const wchar_t *s1, const wchar_t *s2)
-{
-  size_t ns1 = wcslen (s1) + 1;
-  size_t ns2 = wcslen (s2) + 1;
-  size_t n = ns1 < ns2 ? ns1 : ns2;
-  int ret = 0;
-
-  wchar_t c1, c2;
-
-  while (n--) {
-    c1 = *s1++;
-    c2 = *s2++;
-    if ((ret = c1 < c2 ? -1 : c1 == c2 ? 0 : 1) != 0)
-      break;
-  }
-  return ret;
-}
-
 #else
 # include <limits.h>
 
 # define L(str) str
 # define SIMPLE_STRCMP simple_strcmp
-# define STUPID_STRCMP stupid_strcmp
 # define CHARBYTESLOG 0
 # define MIDCHAR 0x7f
 # define LARGECHAR 0xfe
@@ -90,26 +69,12 @@  simple_strcmp (const char *s1, const char *s2)
   return ret;
 }
 
-int
-stupid_strcmp (const char *s1, const char *s2)
-{
-  size_t ns1 = strlen (s1) + 1;
-  size_t ns2 = strlen (s2) + 1;
-  size_t n = ns1 < ns2 ? ns1 : ns2;
-  int ret = 0;
-
-  while (n--)
-    if ((ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) != 0)
-      break;
-  return ret;
-}
 #endif
 
 # include "json-lib.h"
 
 typedef int (*proto_t) (const CHAR *, const CHAR *);
 
-IMPL (STUPID_STRCMP, 1)
 IMPL (SIMPLE_STRCMP, 1)
 IMPL (STRCMP, 1)
 
diff --git a/benchtests/bench-strcspn.c b/benchtests/bench-strcspn.c
index c5d723d983bdcf40c5c845f2c2cc0f1a29925325..bf9c4f8db39940d321323ca4750395efdadcaa37 100644
--- a/benchtests/bench-strcspn.c
+++ b/benchtests/bench-strcspn.c
@@ -28,17 +28,13 @@ 
 
 #ifndef WIDE
 # define SIMPLE_STRCSPN simple_strcspn
-# define STUPID_STRCSPN stupid_strcspn
 #else
 # define SIMPLE_STRCSPN simple_wcscspn
-# define STUPID_STRCSPN stupid_wcscspn
 #endif /* WIDE */
 
 typedef size_t (*proto_t) (const CHAR *, const CHAR *);
 size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
-size_t STUPID_STRCSPN (const CHAR *, const CHAR *);
 
-IMPL (STUPID_STRCSPN, 0)
 IMPL (SIMPLE_STRCSPN, 0)
 IMPL (STRCSPN, 1)
 
@@ -55,17 +51,4 @@  SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
   return s - str - 1;
 }
 
-size_t
-STUPID_STRCSPN (const CHAR *s, const CHAR *rej)
-{
-  size_t ns = STRLEN (s), nrej = STRLEN (rej);
-  size_t i, j;
-
-  for (i = 0; i < ns; ++i)
-    for (j = 0; j < nrej; ++j)
-      if (s[i] == rej[j])
-	return i;
-  return i;
-}
-
 #include "bench-strpbrk.c"
diff --git a/benchtests/bench-strlen.c b/benchtests/bench-strlen.c
index b1cd2accb487293f37a5b5510e396f7310f99f6a..f86095a5d3ce1746b7c0a37d29799a8fe4c83f87 100644
--- a/benchtests/bench-strlen.c
+++ b/benchtests/bench-strlen.c
@@ -34,15 +34,6 @@  size_t memchr_strlen (const CHAR *);
 IMPL (memchr_strlen, 0)
 IMPL (generic_strlen, 0)
 
-#ifndef WIDE
-size_t
-builtin_strlen (const CHAR *p)
-{
-  return __builtin_strlen (p);
-}
-IMPL (builtin_strlen, 0)
-#endif
-
 size_t
 memchr_strlen (const CHAR *p)
 {
diff --git a/benchtests/bench-strncasecmp.c b/benchtests/bench-strncasecmp.c
index e18302a9c4fdf04474c39d5cbaf85ef511310072..7c97877112ca2210bb54de2764a979281d67e8b7 100644
--- a/benchtests/bench-strncasecmp.c
+++ b/benchtests/bench-strncasecmp.c
@@ -23,9 +23,7 @@ 
 
 typedef int (*proto_t) (const char *, const char *, size_t);
 static int simple_strncasecmp (const char *, const char *, size_t);
-static int stupid_strncasecmp (const char *, const char *, size_t);
 
-IMPL (stupid_strncasecmp, 0)
 IMPL (simple_strncasecmp, 0)
 IMPL (strncasecmp, 1)
 
@@ -48,27 +46,6 @@  simple_strncasecmp (const char *s1, const char *s2, size_t n)
   return ret;
 }
 
-static int
-stupid_strncasecmp (const char *s1, const char *s2, size_t max)
-{
-  size_t ns1 = strlen (s1) + 1;
-  size_t ns2 = strlen (s2) + 1;
-  size_t n = ns1 < ns2 ? ns1 : ns2;
-  if (n > max)
-    n = max;
-  int ret = 0;
-
-  while (n--)
-    {
-      if ((ret = ((unsigned char) tolower (*s1)
-		  - (unsigned char) tolower (*s2))) != 0)
-	break;
-      ++s1;
-      ++s2;
-    }
-  return ret;
-}
-
 static void
 do_one_test (impl_t *impl, const char *s1, const char *s2, size_t n,
 	     int exp_result)
diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c
index 750150c245b05171068653234daabdc4f7a6ca2b..a4f3412a8fed49fdf1813974031827fc92fdd8f3 100644
--- a/benchtests/bench-strncmp.c
+++ b/benchtests/bench-strncmp.c
@@ -28,7 +28,6 @@ 
 #ifdef WIDE
 # define L(str) L##str
 # define SIMPLE_STRNCMP simple_wcsncmp
-# define STUPID_STRNCMP stupid_wcsncmp
 
 /* Wcsncmp uses signed semantics for comparison, not unsigned.
    Avoid using substraction since possible overflow.  */
@@ -47,29 +46,9 @@  simple_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
   return 0;
 }
 
-int
-stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n)
-{
-  wchar_t c1, c2;
-  size_t ns1 = wcsnlen (s1, n) + 1, ns2 = wcsnlen (s2, n) + 1;
-
-  n = ns1 < n ? ns1 : n;
-  n = ns2 < n ? ns2 : n;
-
-  while (n--)
-    {
-      c1 = *s1++;
-      c2 = *s2++;
-      if (c1 != c2)
-	return c1 > c2 ? 1 : -1;
-    }
-  return 0;
-}
-
 #else
 # define L(str) str
 # define SIMPLE_STRNCMP simple_strncmp
-# define STUPID_STRNCMP stupid_strncmp
 
 /* Strncmp uses unsigned semantics for comparison.  */
 int
@@ -82,23 +61,10 @@  simple_strncmp (const char *s1, const char *s2, size_t n)
   return ret;
 }
 
-int
-stupid_strncmp (const char *s1, const char *s2, size_t n)
-{
-  size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1;
-  int ret = 0;
-
-  n = ns1 < n ? ns1 : n;
-  n = ns2 < n ? ns2 : n;
-  while (n-- && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
-  return ret;
-}
-
 #endif /* !WIDE */
 
 typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
 
-IMPL (STUPID_STRNCMP, 0)
 IMPL (SIMPLE_STRNCMP, 0)
 IMPL (STRNCMP, 1)
 
diff --git a/benchtests/bench-strpbrk.c b/benchtests/bench-strpbrk.c
index 61639cfd5b055145b727b7e7c5dc4316a225de3d..14e1bcb873fa86caa1f50a9013f52cd422e74185 100644
--- a/benchtests/bench-strpbrk.c
+++ b/benchtests/bench-strpbrk.c
@@ -37,17 +37,13 @@ 
 
 # ifndef WIDE
 #  define SIMPLE_STRPBRK simple_strpbrk
-#  define STUPID_STRPBRK stupid_strpbrk
 # else
 #  define SIMPLE_STRPBRK simple_wcspbrk
-#  define STUPID_STRPBRK stupid_wcspbrk
 # endif /* WIDE */
 
 typedef CHAR *(*proto_t) (const CHAR *, const CHAR *);
 CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *);
-CHAR *STUPID_STRPBRK (const CHAR *, const CHAR *);
 
-IMPL (STUPID_STRPBRK, 0)
 IMPL (SIMPLE_STRPBRK, 0)
 IMPL (STRPBRK, 1)
 
@@ -64,18 +60,6 @@  SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej)
   return NULL;
 }
 
-CHAR *
-STUPID_STRPBRK (const CHAR *s, const CHAR *rej)
-{
-  size_t ns = STRLEN (s), nrej = STRLEN (rej);
-  size_t i, j;
-
-  for (i = 0; i < ns; ++i)
-    for (j = 0; j < nrej; ++j)
-      if (s[i] == rej[j])
-	return (CHAR *) s + i;
-  return NULL;
-}
 #endif /* !STRPBRK_RESULT */
 
 static void
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
index 04507cdd61be04baec9a441baf348dcbde2928d3..ac874fe234af66ad98a6188099f32c10484452db 100644
--- a/benchtests/bench-strspn.c
+++ b/benchtests/bench-strspn.c
@@ -28,19 +28,15 @@ 
 
 #ifndef WIDE
 # define SIMPLE_STRSPN simple_strspn
-# define STUPID_STRSPN stupid_strspn
 # define SMALL_CHAR 127
 #else
 # define SIMPLE_STRSPN simple_wcsspn
-# define STUPID_STRSPN stupid_wcsspn
 # define SMALL_CHAR 1273
 #endif /* WIDE */
 
 typedef size_t (*proto_t) (const CHAR *, const CHAR *);
 size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
-size_t STUPID_STRSPN (const CHAR *, const CHAR *);
 
-IMPL (STUPID_STRSPN, 0)
 IMPL (SIMPLE_STRSPN, 0)
 IMPL (STRSPN, 1)
 
@@ -61,23 +57,6 @@  SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
   return s - str - 1;
 }
 
-size_t
-STUPID_STRSPN (const CHAR *s, const CHAR *acc)
-{
-  size_t ns = STRLEN (s), nacc = STRLEN (acc);
-  size_t i, j;
-
-  for (i = 0; i < ns; ++i)
-    {
-      for (j = 0; j < nacc; ++j)
-	if (s[i] == acc[j])
-	  break;
-      if (j == nacc)
-	return i;
-    }
-  return i;
-}
-
 static void
 do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
 {