[PATCH 4/4] RISC-V: strcmp [speed optimized]: optimize mismatch logic for targets with Zb* extension support

Kito Cheng kito.cheng@gmail.com
Wed May 28 06:56:55 GMT 2025


Hi Puranikvinit:

Thanks for your patch, it's really great improvement for the byte
difference detection!

just one minor comment around the code:

> -  ret
> +    #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> +      ctz a5, a4
> +    #else
> +      clz a5, a4
> +    #endif
> +    andi a5, a5, -8
> +
> +    srl a2, a2, a5
> +    and a2, a2, 0xff

It's great improvement but could you add few comment to explain the
magic here ? :)

> +
> +    srl a3, a3, a5
> +    and a3, a3, 0xff
> +
> +    sub a0, a2, a3
> +    ret
> +  #else


More information about the Newlib mailing list