From: Lulu Cheng <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, gcc-patches@gcc.gnu.org
Cc: Wang Xuerui <i@xen0n.name>, Chenghua Xu <xuchenghua@loongson.cn>
Subject: Re: [PATCH] LoongArch: implement count_{leading,trailing}_zeros
Date: Thu, 13 Oct 2022 16:43:51 +0800 [thread overview]
Message-ID: <53649638-7e6f-508f-b590-a66388c806b4@loongson.cn> (raw)
In-Reply-To: <20221012142300.16833-1-xry111@xry111.site>
Looks good to me!
Thanks!
在 2022/10/12 下午10:23, Xi Ruoyao 写道:
> LoongArch always support clz and ctz instructions, so we can always use
> __builtin_{clz,ctz} for count_{leading,trailing}_zeros. This improves
> the code of libgcc, and also benefits Glibc once we merge longlong.h
> there.
>
> Bootstrapped and regtested on loongarch64-linux-gnu.
>
> include/ChangeLog:
>
> * longlong.h [__loongarch__] (count_leading_zeros): Define.
> [__loongarch__] (count_trailing_zeros): Likewise.
> [__loongarch__] (COUNT_LEADING_ZEROS_0): Likewise.
> ---
> include/longlong.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/longlong.h b/include/longlong.h
> index 64a7b10f9b2..c3a6f1e7eaa 100644
> --- a/include/longlong.h
> +++ b/include/longlong.h
> @@ -593,6 +593,18 @@ extern UDItype __umulsidi3 (USItype, USItype);
> #define UMUL_TIME 14
> #endif
>
> +#ifdef __loongarch__
> +# if W_TYPE_SIZE == 32
> +# define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
> +# define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
> +# define COUNT_LEADING_ZEROS_0 32
> +# elif W_TYPE_SIZE == 64
> +# define count_leading_zeros(count, x) ((count) = __builtin_clzll (x))
> +# define count_trailing_zeros(count, x) ((count) = __builtin_ctzll (x))
> +# define COUNT_LEADING_ZEROS_0 64
> +# endif
> +#endif
> +
> #if defined (__M32R__) && W_TYPE_SIZE == 32
> #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
> /* The cmp clears the condition bit. */ \
next prev parent reply other threads:[~2022-10-13 8:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 14:23 Xi Ruoyao
2022-10-13 8:43 ` Lulu Cheng [this message]
2022-10-13 10:06 ` pushed: " Xi Ruoyao
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=53649638-7e6f-508f-b590-a66388c806b4@loongson.cn \
--to=chenglulu@loongson.cn \
--cc=gcc-patches@gcc.gnu.org \
--cc=i@xen0n.name \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/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).