This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: bzero/bcopy/bcmp/mempcpy (was: Improve strncpy performance further)
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: "'Joseph Myers'" <joseph at codesourcery dot com>
- Cc: 'Ondřej Bílka' <neleai at seznam dot cz>, "'Roland McGrath'" <roland at hack dot frob dot com>, <libc-alpha at sourceware dot org>
- Date: Wed, 4 Feb 2015 18:42:50 -0000
- Subject: RE: bzero/bcopy/bcmp/mempcpy (was: Improve strncpy performance further)
- Authentication-results: sourceware.org; auth=none
- References: <001801d02b72$6ce0c3c0$46a24b40$ at com> <20150108185812 dot 285782C3BF6 at topped-with-meat dot com> <001901d02c0d$43cf9920$cb6ecb60$ at com> <20150109191632 dot 694692C3C1F at topped-with-meat dot com> <001a01d02dc9$bd6f0370$384d0a50$ at com> <20150113191449 dot AD91B2C39DC at topped-with-meat dot com> <001e01d03003$f67b8670$e3729350$ at com> <20150114193244 dot 44C022C39DB at topped-with-meat dot com> <002101d030da$c05f76f0$411e64d0$ at com> <20150131203619 dot GA13121 at domone dot leoexpresswifi dot com> <002b01d04097$ec2c9b10$c485d130$ at com> <alpine dot DEB dot 2 dot 10 dot 1502041726450 dot 4240 at digraph dot polyomino dot org dot uk>
> Joseph Myers wrote:
> On Wed, 4 Feb 2015, Wilco Dijkstra wrote:
>
> > That is certainly a good idea - I added _memclr to armcc a long time ago
> > as 99% of uses of memset set it to zero and don't use the return value
> > (and the cost of save/restore the return value inside memcpy/memset is
> > higher than just recomputing it on most targets).
>
> On ARM there's __aeabi_memclr (and __aeabi_memclr4 and __aeabi_memclr8),
> but the __aeabi_mem* functions are mostly currently implemented as
> wrappers (__aeabi_memcpy* as aliases for __memcpy_arm in the
> armv7/multiarch case, to avoid clobbering NEON registers) and there's no
> GCC support for generating calls to those functions (which would only be
> useful with glibc if they were actually more efficient rather than
> wrappers).
Indeed it's unfortunate that these as well as the generic __bzero are
inefficient. Would it be possible for GCC to detect a modern GLIBC from the
headers and only emit calls to __bzero (or say a new __memclr symbol) if a
target provides an optimized version? Not sure whether there is already a way
to do this, or whether such trickery is discouraged...
Wilco