From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
"Joseph S. Myers" <joseph@codesourcery.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c-family, middle-end: Add __builtin_c[lt]zg (arg, 0ULL) exception
Date: Mon, 20 Nov 2023 08:58:25 +0000 (UTC) [thread overview]
Message-ID: <nycvar.YFH.7.77.849.2311200857160.8772@jbgna.fhfr.qr> (raw)
In-Reply-To: <ZVsdXI8keQ94lTBf@tucnak>
On Mon, 20 Nov 2023, Jakub Jelinek wrote:
> On Mon, Nov 20, 2023 at 08:37:55AM +0000, Richard Biener wrote:
> > > I'm not sure about that, it would be nice for them to be usable there,
> >
> > Btw, I think that {( .. )} should be made usable in sizeof () and
> > possibly even in at least C++ constant expressions (not sure about C).
>
> I believe the problkem is having new VAR_DECLs in those which actually
> aren't file scope/namespace scope variables but there is no function
> DECL_CONTEXT to attach to them. So, it probably wouldn't be one afternoon
> change to allow that.
>
> > > but I think e.g. none of Joseph's implementation of those macros
> > > made them usable there (except inside of sizeof/typeof/typeof_unquall)
> > > and I don't see a requirement in the C23 standard that they must be usable
> > > in constant expressions.
> > > The versions I've posted on Thursday were usable there except for
> > > stdc_has_single_bit (but that actually can be implemented that way too)
> > > and stdc_bit_floor. And the version I haven't posted that used the 3
> > > patches posted on Saturday would have all functions usable when the
> > > argument to those macros is a constant expression.
> > >
> > > BTW, if we go route of implementing all of the stdc_ type-generic macros
> > > as builtins, we could as well not implement that way the following 4
> > > # define stdc_first_leading_one(x) (__builtin_clzg (x, -1) + 1U)
> > > # define stdc_first_trailing_one(x) (__builtin_ctzg (x, -1) + 1U)
> > > # define stdc_count_ones(x) ((unsigned int) __builtin_popcountg (x))
> > > # define stdc_has_single_bit(x) ((_Bool) (__builtin_popcountg (x) == 1))
> > > which are implementable without any new extensions.
> >
> > I'd rather do all of those necessary as builtins instead of hacking
> > around limitations. If we don't want to solve those limitations in
> > a more generic way.
>
> Ok, I can prepare a patch for that, shouldn't be that hard.
> Do you want all 14, or just the 10 and leave the above 4 with the
> above definitions?
I'd say all of them for consistency, we can parse/gimplify them to
the open-coded variants then.
> > And of course nobody would write
> >
> > const int x = sizeof (stdc_first_leading_one (5));
> >
> > that's just stupid ... (but oh well).
>
> Well, standard testsuite needs to include that at least.
> But of course, if it is usable in constant expressions,
> unsigned a = stdc_bit_width ((unsigned _BitInt(824)) 435987349856735489657489657468954768954674589674598uwb * 49876558967549867548967548967548967549867548967456uwb);
> etc. can be useful in constant expressions.
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
next prev parent reply other threads:[~2023-11-20 8:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 19:30 Jakub Jelinek
2023-11-20 7:44 ` Richard Biener
2023-11-20 7:49 ` Richard Biener
2023-11-20 8:19 ` Jakub Jelinek
2023-11-21 0:12 ` Joseph Myers
2023-11-21 8:30 ` Jakub Jelinek
2023-11-20 8:13 ` Jakub Jelinek
2023-11-20 8:18 ` Florian Weimer
2023-11-20 8:31 ` Jakub Jelinek
2023-11-20 8:37 ` Richard Biener
2023-11-20 8:48 ` Jakub Jelinek
2023-11-20 8:58 ` Richard Biener [this message]
2023-11-21 5:59 ` Martin Uecker
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=nycvar.YFH.7.77.849.2311200857160.8772@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=fweimer@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
/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).