This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ARM] Optimised strchr and strlen


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]