This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [ARM] Optimised strchr and strlen
- From: David Gilbert <david dot gilbert at linaro dot org>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: libc-ports at sourceware dot org, joseph at codesourcery dot com, patches at linaro dot org
- Date: Wed, 21 Dec 2011 10:56:27 +0000
- Subject: Re: [ARM] Optimised strchr and strlen
- References: <20111219172122.GA10120@davesworkthinkpad> <4EF0F02B.30706@twiddle.net>
On 20 December 2011 20:29, Richard Henderson <rth@twiddle.net> wrote:
> On 12/19/2011 09:21 AM, Dr. David Alan Gilbert wrote:
>> + ? ? @ r1 currently points to the 2nd byte of the word containing the 0
>> + ? ? tst ? ? r2, # CHARTSTMASK(0) ? ?@ 1st character
>> + ? ? bne ? ? 10f
>> + ? ? adds ? ?r1,r1,#1
>> + ? ? tst ? ? r2, # CHARTSTMASK(1) ? ?@ 2nd character
>> + ? ? ittt ? ?eq
>> + ? ? addeq ? r1,r1,#1
>> + ? ? tsteq ? r2, # (3<<15) ? ? ? ? ? @ 2nd & 3rd character
>> + ? ? @ If not the 3rd must be the last one
>> + ? ? addeq ? r1,r1,#1
>
> No need to search -- clz can do that for you.
>
> #ifdef __ARMEL__
> ? ? ? ?rbit ? ?r2, r2
> #endif
> ? ? ? ?clz ? ? r2, r2
> ? ? ? ?lsrs ? ?r2, r2, #3
> ? ? ? ?adds ? ?r1, r1, r2
Hi Richard,
Thanks for the suggestion - I'd seen that form in some code from another
library and decided because of that not to roll it into my code; however
since there have now been 3 separate people who've suggested it to me
independently I don't see why not!
Thanks,
Dave