[v2] Do not transform strchr into rawmemchr
Commit Message
Version 2 of the patch removes the strchr define completely as
suggested:
GLIBC uses strchr (s, '\0') as an idiom to find the end of a string.
This is transformed into rawmemchr by the bits/string2.h header.
However this is generally slower than strlen on most targets, even when
an optimized rawmemchr implementation exists. Since GCC7 optimizes
strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not
transform this to rawmemchr. As GCC recognizes strchr as a builtin,
defining strchr as the builtin is not useful.
Regress passes, OK for commit?
ChangeLog:
2015-11-23 Wilco Dijkstra <wdijkstr@arm.com>
* string/bits/string2.h (strchr): Remove define.
--
Comments
On 11/23/2016 06:19 PM, Wilco Dijkstra wrote:
> -#ifndef _HAVE_STRING_ARCH_strchr
Please post a version which removes the definition of
_HAVE_STRING_ARCH_strchr as well.
Thanks,
Florian
Florian Weimer wrote:
> Please post a version which removes the definition of
> _HAVE_STRING_ARCH_strchr as well.
See https://sourceware.org/ml/libc-alpha/2016-11/msg00853.html
which removes all of the redundant STRING_ARCH defines.
Wilco
@@ -58,16 +58,6 @@
#endif
-#ifndef _HAVE_STRING_ARCH_strchr
-extern void *__rawmemchr (const void *__s, int __c);
-# define strchr(s, c) \
- (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s) \
- && (c) == '\0' \
- ? (char *) __rawmemchr (s, c) \
- : __builtin_strchr (s, c)))
-#endif
-
-
/* Copy SRC to DEST, returning pointer to final NUL byte. */
#ifdef __USE_GNU
# ifndef _HAVE_STRING_ARCH_stpcpy