This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] aarch64: Improve strncmp for mutually misaligned inputs
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: "siddhesh at sourceware dot org" <siddhesh at sourceware dot org>
- Cc: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, nd <nd at arm dot com>
- Date: Wed, 14 Mar 2018 14:04:00 +0000
- Subject: Re: [PATCH] aarch64: Improve strncmp for mutually misaligned inputs
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi,
Why not use lsr limit_wd, limit, 3? We have 3-operand shifts on AArch64!
--- a/sysdeps/aarch64/strncmp.S
+++ b/sysdeps/aarch64/strncmp.S
@@ -208,13 +208,15 @@ L(done):
/* Align the SRC1 to a dword by doing a bytewise compare and then do
the dword loop. */
L(try_misaligned_words):
- mov limit_wd, limit, lsr #3
+ mov limit_wd, limit
+ lsr limit_wd, limit_wd, #3
cbz count, L(do_misaligned)
neg count, count
and count, count, #7
sub limit, limit, count
- mov limit_wd, limit, lsr #3
+ mov limit_wd, limit
+ lsr limit_wd, limit_wd, #3
Also it seems to me it would be far easier to subtract 8 from limit in the main loop.
This means we don't ever need limit_wd, and avoids having to do this later:
/* We found a difference or a NULL before the limit was reached. */
and limit, limit, #7
cbz limit, L(not_limit)
Wilco