* [PATCH] LoongArch: Use builtins for ffs and ffsll
@ 2024-02-04 0:27 Xi Ruoyao
2024-02-05 13:57 ` Adhemerval Zanella Netto
0 siblings, 1 reply; 2+ messages in thread
From: Xi Ruoyao @ 2024-02-04 0:27 UTC (permalink / raw)
To: libc-alpha; +Cc: Adhemerval Zanella Netto, caiyinyu, Xi Ruoyao
On LoongArch GCC compiles __builtin_ffs{,ll} to basically
`(x ? __builtin_ctz (x) : -1) + 1`. Since a hardware ctz instruction is
available, this is much better than the table-driven generic
implementation.
Tested on loongarch64.
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
sysdeps/loongarch/math-use-builtins-ffs.h | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 sysdeps/loongarch/math-use-builtins-ffs.h
diff --git a/sysdeps/loongarch/math-use-builtins-ffs.h b/sysdeps/loongarch/math-use-builtins-ffs.h
new file mode 100644
index 0000000000..a83bb15414
--- /dev/null
+++ b/sysdeps/loongarch/math-use-builtins-ffs.h
@@ -0,0 +1,2 @@
+#define USE_FFS_BUILTIN 1
+#define USE_FFSLL_BUILTIN 1
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] LoongArch: Use builtins for ffs and ffsll
2024-02-04 0:27 [PATCH] LoongArch: Use builtins for ffs and ffsll Xi Ruoyao
@ 2024-02-05 13:57 ` Adhemerval Zanella Netto
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella Netto @ 2024-02-05 13:57 UTC (permalink / raw)
To: Xi Ruoyao, libc-alpha; +Cc: caiyinyu
On 03/02/24 21:27, Xi Ruoyao wrote:
> On LoongArch GCC compiles __builtin_ffs{,ll} to basically
> `(x ? __builtin_ctz (x) : -1) + 1`. Since a hardware ctz instruction is
> available, this is much better than the table-driven generic
> implementation.
>
> Tested on loongarch64.
>
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> sysdeps/loongarch/math-use-builtins-ffs.h | 2 ++
> 1 file changed, 2 insertions(+)
> create mode 100644 sysdeps/loongarch/math-use-builtins-ffs.h
>
> diff --git a/sysdeps/loongarch/math-use-builtins-ffs.h b/sysdeps/loongarch/math-use-builtins-ffs.h
> new file mode 100644
> index 0000000000..a83bb15414
> --- /dev/null
> +++ b/sysdeps/loongarch/math-use-builtins-ffs.h
> @@ -0,0 +1,2 @@
> +#define USE_FFS_BUILTIN 1
> +#define USE_FFSLL_BUILTIN 1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-05 13:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-04 0:27 [PATCH] LoongArch: Use builtins for ffs and ffsll Xi Ruoyao
2024-02-05 13:57 ` Adhemerval Zanella Netto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).