From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 235D0388215B for ; Mon, 20 Nov 2023 08:37:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 235D0388215B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 235D0388215B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700469479; cv=none; b=pWevc92IAqnmkRxdeJw1k0oXIWFskiKhxchtrCppRMUGa7+Qc1yg+Ew2037Tznv1d+5SrGmPxQqzE/kcYNDmS7XK48krAblzZBYzUqOaPvzwB035OUInKOSXhOc5l8bpoPEvIIdpwDTo+mKTJWTZ5VwrNOFdTcvTm6kLX/AmfY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700469479; c=relaxed/simple; bh=IDGRCnTfhNO3L2xCgMntlD0HeYR0Z26ZbqoepqsbAcE=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=FF9M+rp0iVaNohm6jSTS/lFfHIZeoTNHgCuR+s0idSTFdw2NMKO02bd/tZjUxYYb7+auMrf2PE89iZAvU+15klJlrM7vZAKNE9v9oq0dX7Ohoa1+8uGPjl255QodK5IuytZ+YJ4PMmJFdayHzhYMdKwSTTuoF+PDfc50Bgchzt4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3156E218DF; Mon, 20 Nov 2023 08:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700469476; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zcWDqDYrQc5uMWKPmbo0v3YCuFD63LSbWWv+rzQfBlk=; b=kkV7przfYuPQb3dS9DcHSQV/fkt7+HYEih9cRPnbkF0VvG9wuqLGJV83FeSmu4BEF0hY0T pHvikQeLkCyZBuFT5HR+ZXqcbu4xasDEQ2wG90U3d2eIY7Wh+oeCrvebhhxT4zE43VtRli COCArzPB1W58nMOJEqmx0rthiPVzzUg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700469476; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zcWDqDYrQc5uMWKPmbo0v3YCuFD63LSbWWv+rzQfBlk=; b=S7rs2JCorSZi1U8R/qjxeY2k8uKE/fInexN7dKe0TPebt9V9v+GQniyPQVdp2wq7DlhECK PXc9J8y7XNaN39Bg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id F16B72C2AA; Mon, 20 Nov 2023 08:37:55 +0000 (UTC) Date: Mon, 20 Nov 2023 08:37:55 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Florian Weimer , "Joseph S. Myers" , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c-family, middle-end: Add __builtin_c[lt]zg (arg, 0ULL) exception In-Reply-To: Message-ID: References: <87zfz8rg5q.fsf@oldenburg.str.redhat.com> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: +++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd1 X-Spamd-Result: default: False [13.99 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.de]; R_SPF_SOFTFAIL(4.60)[~all:c]; NEURAL_SPAM_SHORT(3.00)[1.000]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; NEURAL_SPAM_LONG(3.50)[1.000]; VIOLATED_DIRECT_SPF(3.50)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 13.99 X-Rspamd-Queue-Id: 3156E218DF X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 20 Nov 2023, Jakub Jelinek wrote: > On Mon, Nov 20, 2023 at 09:18:57AM +0100, Florian Weimer wrote: > > * Richard Biener: > > > > > Ugh. First of all I don't like that the exception is applied during > > > folding. As for the problem of multi evaluation can't consumers use > > > stmt expressions for this, say > > > > > > {( auto __tem = value; __builtin_xyz (__tem, __typeof (__tem)); ... )} > > > > > > ? Thus use 'auto' to avoid spelling 'value' multiple times? > > > > {( ? )} cannot be used in a constant expression, but the new macros are > > supposed to be usable there. > > 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). > 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. And of course nobody would write const int x = sizeof (stdc_first_leading_one (5)); that's just stupid ... (but oh well). Richard.