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 C75553858C35 for ; Mon, 20 Nov 2023 08:32:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C75553858C35 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 C75553858C35 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=1700469127; cv=none; b=v/LusZLZMV2zvQ/AbL8PSkQjh1zp3tovX2+9CNHUPOm9z3yQkQEQaLGhoG68Dl5GhYu6tXPjVtND1rNfW9ocy04VAnlSw/vsx1lSM0fCmveji5s91+x3huDE1BLbMEy5C590hET3WkfJrhjmeRzTQjF1z4B44wZ7K60teynMoTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700469127; c=relaxed/simple; bh=coIOh0y4tTtnMgN7CnL4wvI0aJC/UpfbofwfETVI0WQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=aJX/aagsnh08vOvIz1crTLqYx6Ft5DXu3e5BstT952asWnZ3GOO3KAl/fi4Xl7sjtnpUgG0R9y1oh3dzh3DE0Pq6Stg6aM93aRzPa3Chz9dF4MpVXz484tTSysal9MvYvuyZfdmbOrDryreda7IMtl1hmtpuHuoiQJyGIEzU51E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700469125; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izeGk+D5LZoBTwYxAadoNEe+I8T4vzNno3shXQjo7ao=; b=Cul6ZZKyoncqCZQjtu6RaBXSqxyLC6jnBq8aKe/8o9lYZ/GNiR08aLRbVovUspCxYRQmUU NiLYv7g5P5YsBeMVkgCqxnLLDEk2qzZ7k0zkI8zHDlRsApFhvSt1WTmP2RAeg0yZ4QQxXp nn4iTmGCPJGOu+ZxZPPgDkMmST6p9OA= 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-467-u7ZKeIM0NtexYrPr0x5mgA-1; Mon, 20 Nov 2023 03:32:01 -0500 X-MC-Unique: u7ZKeIM0NtexYrPr0x5mgA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 5ECFF38143B5; Mon, 20 Nov 2023 08:32:01 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B2741121306; Mon, 20 Nov 2023 08:32:00 +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 3AK8Vw4m1532887 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 09:31:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3AK8Vvvp1532886; Mon, 20 Nov 2023 09:31:57 +0100 Date: Mon, 20 Nov 2023 09:31:57 +0100 From: Jakub Jelinek To: Florian Weimer Cc: Richard Biener , "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: <87zfz8rg5q.fsf@oldenburg.str.redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 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, 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. Jakub