public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Richard Biener <rguenther@suse.de>,
	gcc-patches@gcc.gnu.org, Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH] c-family, middle-end: Add __builtin_c[lt]zg (arg, 0ULL) exception
Date: Tue, 21 Nov 2023 09:30:28 +0100	[thread overview]
Message-ID: <ZVxqpJ3pxVnesHxp@tucnak> (raw)
In-Reply-To: <f2b14cb8-5de3-651e-887a-33b78ba7a87@codesourcery.com>

On Tue, Nov 21, 2023 at 12:12:18AM +0000, Joseph Myers wrote:
> On Mon, 20 Nov 2023, Jakub Jelinek wrote:
> 
> > and be done with that.  If there is an agreement we should do that
> > for all 14 rather than just those 3 + the 2 ugly hacks (__builtin_c{l,t}zg with
> > 0ULL second argument and __builtin_bit_complement), I can change the
> 
> I tend to agree with the "ugly hack" description of the 0ULL second 
> argument special case.

It could be done differently, e.g. by adding optional third argument with
the meaning that if that third argument is present and constant non-zero,
the return value on 0 first argument would be second argument + bitsize
of the first argument, while if the third argument is not present or
constant zero, it is the current behavior of second argument on constant
zero.

Given that I've already posted all 14 __builtin_stdc_*, that isn't
strictly needed for stdbit.h, the only question is if it would be useful
for users in other cases.
If there is the _Generic extension or say even just a new builtin like
__builtin_save_expr (x, y)
which would introduce some special fixed identifier when evaluating y for
the value (but not side-effects) of x, that wouldn't be needed and I agree
going for something like that would be cleaner.

	Jakub


  reply	other threads:[~2023-11-21  8:30 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 [this message]
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
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=ZVxqpJ3pxVnesHxp@tucnak \
    --to=jakub@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.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).