From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 04C6D3858C5F for ; Mon, 20 Nov 2023 08:48:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04C6D3858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 04C6D3858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700470116; cv=none; b=glpbRt4Was791D8TnCeok4SA9LXxfpaPMCM8VMFdmgXjioO9otc9bzRG6+XzFqDB83gUf8ooZZwViLnBDawdqODOaldLataj67WGzp5pJme5dWpjZQBkUByrY9ns6PjAdXE3IOY6iOjEOUkjUSCuhXIDrKxV8qIqIN+kENL42BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700470116; c=relaxed/simple; bh=SIA4ezcYGZxkZI4ytFD3Y+KyZNLKaSEBjCK33oww/3g=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=RMTTsPfnC6/6xdvdC5mYNf2qHm2ntEI1+BMVIoEsSNK4q4ILbNPiN+DEr+TWUNtQimhfqw4BAHSHdUswMqGLsnfYNZdb8GjGDRGGdEwDUr20qw9YbNUkZDkv2HQPEFXlDhPxiKfjHvmDKZ/Z9apquRONjgsKT8/3biuA9uj/nM4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700470114; h=from:from:reply-to:reply-to:subject:subject: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=E9QUU66JJrFkbTjqAqxjXk4x3otj5Skpo9vbbYiaa/k=; b=CFAOMSlJAQRIsXRPcHmywaSRF+adinTSk/KrJ1/Ntw61TN2aRv8WJLsbQ0iMgvf5k/EY9b btFAX+RWEQE2BTKiLfVksPKjVoVZgbVIEi80ctgJhNolywU90C3g3g1VatMNYSk8VuC/V+ v2nN/L/42qDV4uUVg1OaU6cKJ6L1j7I= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-RgdkYQgxNX2h0N-jxwQWzg-1; Mon, 20 Nov 2023 03:48:33 -0500 X-MC-Unique: RgdkYQgxNX2h0N-jxwQWzg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E70ED3C0E64C; Mon, 20 Nov 2023 08:48:32 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97EFA5036; Mon, 20 Nov 2023 08:48:32 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3AK8mTsT1533004 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 09:48:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3AK8mSYg1533003; Mon, 20 Nov 2023 09:48:28 +0100 Date: Mon, 20 Nov 2023 09:48:28 +0100 From: Jakub Jelinek To: Richard Biener 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 Message-ID: Reply-To: Jakub Jelinek References: <87zfz8rg5q.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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, 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? > 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