string: Improve generic strcmp
commit30cf54bf3072be942847400c1669bcd63aab039e
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 10 Jan 2023 21:00:58 +0000 (10 18:00 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 6 Feb 2023 19:19:35 +0000 (6 16:19 -0300)
tree3fb85ccfa434cd8bd8f4047dd4a12ff55bae3a65
parent506f7dbbabbad1f2d9f745636937b20c2670c29b
string: Improve generic strcmp

It follows the strategy:

  - Align the first input to word boundary using byte operations.

  - If second input is also word aligned, read a word per time, check for
    null (using has_zero), and check final words using byte operation.

  - If second input is not word aligned, loop by aligning the source, and
    merging the result of two reads.  Similar to aligned case, check for
    null with has_zero, and check final words using byte operation.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64-linux-gnu,
and powerpc-linux-gnu by removing the arch-specific assembly
implementation and disabling multi-arch (it covers both LE and BE
for 64 and 32 bits).

Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
string/strcmp.c