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 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


r~


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