]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
LoongArch: Use builtins for ffs and ffsll
authorXi Ruoyao <xry111@xry111.site>
Sun, 4 Feb 2024 00:27:50 +0000 (08:27 +0800)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 Feb 2024 18:19:41 +0000 (15:19 -0300)
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>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/loongarch/math-use-builtins-ffs.h [new file with mode: 0644]

diff --git a/sysdeps/loongarch/math-use-builtins-ffs.h b/sysdeps/loongarch/math-use-builtins-ffs.h
new file mode 100644 (file)
index 0000000..a83bb15
--- /dev/null
@@ -0,0 +1,2 @@
+#define USE_FFS_BUILTIN   1
+#define USE_FFSLL_BUILTIN 1