]> git.ipfire.org Git - thirdparty/glibc.git/commit
x86: Optimize memrchr-evex.S
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Jun 2022 04:11:31 +0000 (21:11 -0700)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Jun 2022 20:10:24 +0000 (13:10 -0700)
commitb4209615a06b01c974f47b4998b00e4c7b1aa5d9
treec8583af4c1f5fe43fd032de0b75d523695fc8588
parent731feee3869550e93177e604604c1765d81de571
x86: Optimize memrchr-evex.S

The new code:
    1. prioritizes smaller user-arg lengths more.
    2. optimizes target placement more carefully
    3. reuses logic more
    4. fixes up various inefficiencies in the logic. The biggest
       case here is the `lzcnt` logic for checking returns which
       saves either a branch or multiple instructions.

The total code size saving is: 263 bytes
Geometric Mean of all benchmarks New / Old: 0.755

Regressions:
There are some regressions. Particularly where the length (user arg
length) is large but the position of the match char is near the
beginning of the string (in first VEC). This case has roughly a
20% regression.

This is because the new logic gives the hot path for immediate matches
to shorter lengths (the more common input). This case has roughly
a 35% speedup.

Full xcheck passes on x86_64.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
sysdeps/x86_64/multiarch/memrchr-evex.S