[v2] mips: Use builtins for ffs and ffsll

Message ID 20240206083456.721-1-zhujunxian@oss.cipunited.com
State Committed
Commit 545480506fc6576ea37a14e56c654935c691709d
Delegated to: Maxim Kuvyrkov
Headers
Series [v2] mips: Use builtins for ffs and ffsll |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Junxian Zhu Feb. 6, 2024, 8:34 a.m. UTC
  From: Junxian Zhu <zhujunxian@oss.cipunited.com>

__builtin_ffs{,ll} basically on __builtin_ctz{,ll} in MIPS GCC compiler.
The hardware ctz instructions were available after MIPS{32,64} Release1. By using builtin ctz. It can also reduce code size of ffs/ffsll.

Checked on mips o32. mips64.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
---
 sysdeps/mips/math-use-builtins-ffs.h | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 sysdeps/mips/math-use-builtins-ffs.h
  

Comments

Maxim Kuvyrkov Feb. 13, 2024, 7:45 a.m. UTC | #1
> On Feb 6, 2024, at 12:34, Junxian Zhu <zhujunxian@oss.cipunited.com> wrote:
> 
> From: Junxian Zhu <zhujunxian@oss.cipunited.com>
> 
> __builtin_ffs{,ll} basically on __builtin_ctz{,ll} in MIPS GCC compiler.
> The hardware ctz instructions were available after MIPS{32,64} Release1. By using builtin ctz. It can also reduce code size of ffs/ffsll.
> 
> Checked on mips o32. mips64.
> 
> Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
> ---
> sysdeps/mips/math-use-builtins-ffs.h | 3 +++
> 1 file changed, 3 insertions(+)
> create mode 100644 sysdeps/mips/math-use-builtins-ffs.h

Please CC reviewers of previous patch versions -- Adhemerval in this case.

LGTM.

Do you have commit access?  If not, please ask Adhemerval to merge your patch.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>

Thanks!

> 
> diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h
> new file mode 100644
> index 0000000000..2ab6a03a16
> --- /dev/null
> +++ b/sysdeps/mips/math-use-builtins-ffs.h
> @@ -0,0 +1,3 @@
> +#include <sysdep.h>
> +#define USE_FFS_BUILTIN (__mips_isa_rev >= 1)
> +#define USE_FFSLL_BUILTIN (__mips_isa_rev >= 1)
> -- 
> 2.43.0.windows.1

--
Maxim Kuvyrkov
https://www.linaro.org
  

Patch

diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h
new file mode 100644
index 0000000000..2ab6a03a16
--- /dev/null
+++ b/sysdeps/mips/math-use-builtins-ffs.h
@@ -0,0 +1,3 @@ 
+#include <sysdep.h>
+#define USE_FFS_BUILTIN (__mips_isa_rev >= 1)
+#define USE_FFSLL_BUILTIN (__mips_isa_rev >= 1)