public inbox for
 help / color / mirror / Atom feed
From: Xi Ruoyao <>
Cc: Adhemerval Zanella Netto <>,, Xi Ruoyao <>
Subject: [PATCH] LoongArch: Use builtins for ffs and ffsll
Date: Sun,  4 Feb 2024 08:27:50 +0800	[thread overview]
Message-ID: <> (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

Tested on loongarch64.

Signed-off-by: Xi Ruoyao <>
 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

             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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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).