public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	Richard Biener <rguenther@suse.de>,
	Jason Merrill <jason@redhat.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Add type-generic clz/ctz/clrsb/ffs/parity/popcount builtins [PR111309]
Date: Sat, 16 Dec 2023 09:36:13 +0100	[thread overview]
Message-ID: <ZX1hfWktdwMuhsED@tucnak> (raw)
In-Reply-To: <CA+=Sn1=7byKKMP5JxWkaT3iKzi6t1N4eWDQOnxB4JVXCLxaE8g@mail.gmail.com>

On Fri, Dec 15, 2023 at 09:51:10PM -0800, Andrew Pinski wrote:
> I was looking into improving __builtin_popcountg for __int128 on
> aarch64 (when CSSC is not implemented which right now is almost all
> cores) but this patch forces __builtin_popcountg to expand into 2
> __builtin_popcountll (and add) before it could optimize into an
> internal function for the popcount and have the backend a possibility
> of using implementing something better.
> This is due to the code in fold_builtin_bit_query, what might be the
> best way of disabling that for this case?
> 
> Basically right now popcount is implemented using the SIMD instruction
> cnt which can be used either 8x1 or 16x1 wide. Using the 16x1 improves
> both the code size and performance (on almost all cores I know of). So
> instead of 2 cnt instructions, we only would need one.

The reason for lowering those 2 * wordsize cases early is that there
is no __builtin_{clz,ctz,clrsb,ffs,parity,popcount}* for those cases (so we
can't expect expansion to say libgcc routines as fallback) and
IFN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT} are still direct optab ifns
(now with the extension that large/huge _BitInt is ok for those as operands
because we are guaranteed to lower that during bitint lowering).
Anything else won't make it through the direct optab checks and won't be
guaranteed to expand.

You can always define optabs for those and handle them in md files if it
results in better code.

	Jakub


      reply	other threads:[~2023-12-16  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09 15:02 Jakub Jelinek
2023-11-09 21:43 ` Joseph Myers
2023-11-10  8:09 ` Richard Biener
2023-11-10  9:10   ` Jakub Jelinek
2023-11-10  9:19     ` Richard Biener
2023-11-10  9:44       ` Jakub Jelinek
2023-11-11  8:18         ` Jakub Jelinek
2023-11-13 23:45     ` Joseph Myers
2023-12-16  5:51 ` Andrew Pinski
2023-12-16  8:36   ` Jakub Jelinek [this message]

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=ZX1hfWktdwMuhsED@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=pinskia@gmail.com \
    --cc=rguenther@suse.de \
    /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).