x86: Optimize memrchr-evex.S
authorNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 19 Oct 2022 00:44:06 +0000 (17:44 -0700)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 20 Oct 2022 00:31:03 +0000 (17:31 -0700)
commit4af6844aa5d3577e327f15dd877a38a043cb236a
tree8032676690c0b37aee3c26e5dde1bb600289ef4e
parentb79f8ff26aa6151d2d2167afcddcd1ec46cfbc81
x86: Optimize memrchr-evex.S

Optimizations are:
1. Use the fact that lzcnt(0) -> VEC_SIZE for memchr to save a branch
   in short string case.
2. Save several instructions in len = [VEC_SIZE, 4 * VEC_SIZE] case.
3. Use more code-size efficient instructions.
- tzcnt ...     -> bsf ...
- vpcmpb $0 ... -> vpcmpeq ...

Code Size Changes:
memrchr-evex.S      :  -29 bytes

Net perf changes:

Reported as geometric mean of all improvements / regressions from N=10
runs of the benchtests. Value as New Time / Old Time so < 1.0 is
improvement and 1.0 is regression.

memrchr-evex.S      : 0.949 (Mostly from improvements in small strings)

Full results attached in email.

Full check passes on x86-64.
sysdeps/x86_64/multiarch/memrchr-evex.S