This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 08/27] S390: Optimize strnlen and wcsnlen.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Stefan Liebler <stli at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 26 Jun 2015 15:12:35 +0200
- Subject: Re: [PATCH 08/27] S390: Optimize strnlen and wcsnlen.
- Authentication-results: sourceware.org; auth=none
- References: <1435319512-22245-1-git-send-email-stli at linux dot vnet dot ibm dot com> <1435319512-22245-9-git-send-email-stli at linux dot vnet dot ibm dot com>
On Fri, Jun 26, 2015 at 01:51:33PM +0200, Stefan Liebler wrote:
> This patch provides optimized versions of strnlen and wcsnlen with the z13
> vector instructions.
snip
> + /* Find zero in 16 byte aligned loop. */
> +.Lloop1:
> + vl %v16,0(%r5,%r2) /* Load s. */
> + aghi %r5,16
> + vfenezbs %v16,%v16,%v16 /* Find element not equal with zero search. */
> + je .Lfound /* Jump away if zero was found. */
> + clgrjhe %r5,%r3,.Lfound /* current_len >= maxlen -> end. */
> + vl %v16,0(%r5,%r2)
> + aghi %r5,16
> + vfenezbs %v16,%v16,%v16
> + je .Lfound
> + clgrjhe %r5,%r3,.Lfound
> + vl %v16,0(%r5,%r2)
> + aghi %r5,16
> + vfenezbs %v16,%v16,%v16
> + je .Lfound
> + clgrjhe %r5,%r3,.Lfound
> + vl %v16,0(%r5,%r2)
> + aghi %r5,16
> + vfenezbs %v16,%v16,%v16
> + je .Lfound
> + clgrjl %r5,%r3,.Lloop1 /* maxlen not reached -> loop. */
While I couldn't find any program that calls strnlen and one could argue
to optimize this for size this also looks bit suboptimal.
Here you could expand prologue with four checks to be make loop 64-byte
aligned. Then you could check maxlen only once per 64 bytes.