[PATCH v12 14/31] string: Improve generic strrchr with memrchr and strlen

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Feb 3 12:15:38 GMT 2023



On 02/02/23 16:54, Wilco Dijkstra wrote:
> Hi Adhemerval,
> 
>  STRRCHR (const char *s, int c)
>  {
> +  return __memrchr (s, c, strlen (s) + 1);
>  }
> 
> LGTM
> 
> I did a quick check on AArch64 and the speedup vs the old generic version
> on bench-strrchr is 9.9 times! It's ~15% slower overall than the assembler
> strrchr.
> 
> While the benchmark is not perfect, it shows that if you have decent strlen
> and memrchr then strlen+memchr gives a competitive strrchr.

Yeah, I saw a similar improvement on my side as well.  Thanks for verify it
as well.


More information about the Libc-alpha mailing list