[PATCH v2] RISC-V: Use __builtin_ffs when zbb is enabled

Khem Raj raj.khem@gmail.com
Mon Jan 27 02:25:04 GMT 2025


On Sun, Jan 26, 2025 at 6:19 PM Anton Blanchard <antonb@tenstorrent.com>
wrote:

> Using __builtin_ffs when zbb is enabled takes __ffs from 26
> instructions to 5.
> ---
>  sysdeps/riscv/math-use-builtins-ffs.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>  create mode 100644 sysdeps/riscv/math-use-builtins-ffs.h
>
> diff --git a/sysdeps/riscv/math-use-builtins-ffs.h
> b/sysdeps/riscv/math-use-builtins-ffs.h
> new file mode 100644
> index 0000000000..836958565b
> --- /dev/null
> +++ b/sysdeps/riscv/math-use-builtins-ffs.h
> @@ -0,0 +1,7 @@
> +#if __GNUC_PREREQ (12, 0) && defined __riscv_zbb


Do we need to check for gcc version ?
It would be more portable if we did not have to


> +#define USE_FFS_BUILTIN   1
> +#define USE_FFSLL_BUILTIN 1
> +#else
> +#define USE_FFS_BUILTIN   0
> +#define USE_FFSLL_BUILTIN 0
> +#endif
> --
> 2.34.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250126/2ccdfabc/attachment.htm>


More information about the Libc-alpha mailing list