From: Xi Ruoyao <xry111@xry111.site>
To: libc-alpha@sourceware.org
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
caiyinyu@loongson.cn, Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH] LoongArch: Use builtins for ffs and ffsll
Date: Sun, 4 Feb 2024 08:27:50 +0800 [thread overview]
Message-ID: <20240204002750.402652-1-xry111@xry111.site> (raw)
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
next reply other threads:[~2024-02-04 0:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-04 0:27 Xi Ruoyao [this message]
2024-02-05 13:57 ` Adhemerval Zanella Netto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240204002750.402652-1-xry111@xry111.site \
--to=xry111@xry111.site \
--cc=adhemerval.zanella@linaro.org \
--cc=caiyinyu@loongson.cn \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).