Message ID | ZQlMfsN2tNELdv0B@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3191962vqi; Tue, 19 Sep 2023 00:24:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9L2zAyER2afUB2mHVmwp5EtoTmSJHLrR2shWooIT4M9LP4waBx+ScA/oSR0e49vXd7KSP X-Received: by 2002:a17:906:5183:b0:9a1:fb4c:3b6c with SMTP id y3-20020a170906518300b009a1fb4c3b6cmr9536486ejk.59.1695108271456; Tue, 19 Sep 2023 00:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695108271; cv=none; d=google.com; s=arc-20160816; b=Pz1NwO9nRv7j7W3Dmvw00UwW93CEK2WC7kUB1S9E/4mb5q8IFkU0lcOu4czwb9HbKF 3YcHFqKNkPSo5zqXIfhak7CwcCLRwcjOVFgVlZll8/P+xcTY8fLcNvtejZyTt1mywl9i xmJjWRMXtXrorrXx8/KPne2nvx1QiKCiPsVb4oXWz1phPdrM79oQ/pc746x1B7powFh+ MdxPW8ZvmjvGhHeH29eH6b+xKgcWT17H86enNYwfCBaf5NcfUj5gnVEoobLg5aL5/0AI zWAcBVEp98rs3CzNqs5Ap69JprDcDG0YHyHft32/QNdR2rMkmTJr/Qw88CSSZvDulbZ6 cF+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:cc:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=WnehWPHOAy48XnoV4aYmMBSxKnPM+CI4NusuzrF8igM=; fh=54p950vmtjTD/MU8XaJ55TuffbJGYSEmu0yS3GxULKA=; b=mZIM+ZzaEPl6vLFrz+CwiLIZXA+rK6MvbSUsnrA1C7G3ibUQxo0TA6ISLJo29AMhQc oAbCt9+0KdsJzJAB3RuG+NlJH/bQhomVQRROYOu99bvCGBzMZfLo3SG8SiGDiICjC02f UgqHvaswoLdGQ1lhMQwR7LpnK4vfCRyKDFVkd9FhqlkktTpz3eKzJJYfw9p5Ucq6GmCM JHXn4Tz6bw5jfADkef9EQDTavWVSMGBrQYkQ5LLji2V1L+hdiGLCMGkmlu2bs28f6b9N S+uOuY/kWYqDwtb8Okcx1uBJdXAWr9bRypd/heLgq7oAqfsUaG2itUATk5asDIAtqzXb 7+SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GsMEd+19; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id op7-20020a170906bce700b00992e0e54464si9489434ejb.254.2023.09.19.00.24.31 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 00:24:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GsMEd+19; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27252385771C for <ouuuleilei@gmail.com>; Tue, 19 Sep 2023 07:24:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27252385771C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695108270; bh=WnehWPHOAy48XnoV4aYmMBSxKnPM+CI4NusuzrF8igM=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GsMEd+193i8n7QyZ0emNRitKQ57u534mXf1F7HwXkXgGmrPRrlL6i6ETRMEgwyEuK n+d3CStYQGD+upsz/18cwpzp/D8bV0CyswPrKaoeO/u9YUljrPPg3QMGgBxWPdW1pA Po2dL+lCW5FkHUQQbaeamCBl+KGahQkZ8Ct98C3I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 B84813858D32 for <gcc-patches@gcc.gnu.org>; Tue, 19 Sep 2023 07:23:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B84813858D32 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-677-mpA3XasmOHqxKAGZuC8phQ-1; Tue, 19 Sep 2023 03:23:45 -0400 X-MC-Unique: mpA3XasmOHqxKAGZuC8phQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45E473800BB1; Tue, 19 Sep 2023 07:23:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C761D492B16; Tue, 19 Sep 2023 07:23:44 +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 38J7Nh5n2523113 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 09:23:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 38J7NgA02523112; Tue, 19 Sep 2023 09:23:42 +0200 Date: Tue, 19 Sep 2023 09:23:42 +0200 To: Richard Biener <rguenther@suse.de>, Joseph Myers <joseph@codesourcery.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] v2: small _BitInt tweaks Message-ID: <ZQlMfsN2tNELdv0B@tucnak> References: <ZP9RahtJvkQl7PFG@tucnak> <nycvar.YFH.7.77.849.2309121020430.5561@jbgna.fhfr.qr> <ZQBLAUKxj5Wo3wKk@tucnak> <7d2d63ec-b160-5757-1f6b-67b4126c5b85@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <7d2d63ec-b160-5757-1f6b-67b4126c5b85@codesourcery.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=-0.9 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, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777449850497222138 X-GMAIL-MSGID: 1777449850497222138 |
Series |
v2: small _BitInt tweaks
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Sept. 19, 2023, 7:23 a.m. UTC
Hi! On Tue, Sep 12, 2023 at 05:27:30PM +0000, Joseph Myers wrote: > On Tue, 12 Sep 2023, Jakub Jelinek via Gcc-patches wrote: > > > And by ensuring we never create 1-bit signed BITINT_TYPE e.g. the backends > > don't need to worry about them. > > > > But I admit I don't feel strongly about that. > > > > Joseph, what do you think about this? > > I think it's appropriate to avoid 1-bit signed BITINT_TYPE consistently. Here is a patch which does that. In addition to the previously changed two hunks it also adds a checking assertion that we don't create signed _BitInt(0), unsigned _BitInt(0) or signed _BitInt(1) types. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-09-18 Jakub Jelinek <jakub@redhat.com> gcc/ * tree.cc (build_bitint_type): Assert precision is not 0, or for signed types 1. (signed_or_unsigned_type_for): Return INTEGER_TYPE for signed variant of unsigned _BitInt(1). gcc/c-family/ * c-common.cc (c_common_signed_or_unsigned_type): Return INTEGER_TYPE for signed variant of unsigned _BitInt(1). Jakub
Comments
On Tue, 19 Sep 2023, Jakub Jelinek wrote: > Hi! > > On Tue, Sep 12, 2023 at 05:27:30PM +0000, Joseph Myers wrote: > > On Tue, 12 Sep 2023, Jakub Jelinek via Gcc-patches wrote: > > > > > And by ensuring we never create 1-bit signed BITINT_TYPE e.g. the backends > > > don't need to worry about them. > > > > > > But I admit I don't feel strongly about that. > > > > > > Joseph, what do you think about this? > > > > I think it's appropriate to avoid 1-bit signed BITINT_TYPE consistently. > > Here is a patch which does that. In addition to the previously changed two > hunks it also adds a checking assertion that we don't create > signed _BitInt(0), unsigned _BitInt(0) or signed _BitInt(1) types. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Thanks, Richard. > 2023-09-18 Jakub Jelinek <jakub@redhat.com> > > gcc/ > * tree.cc (build_bitint_type): Assert precision is not 0, or > for signed types 1. > (signed_or_unsigned_type_for): Return INTEGER_TYPE for signed variant > of unsigned _BitInt(1). > gcc/c-family/ > * c-common.cc (c_common_signed_or_unsigned_type): Return INTEGER_TYPE > for signed variant of unsigned _BitInt(1). > > --- gcc/tree.cc.jj 2023-09-11 17:01:17.612714178 +0200 > +++ gcc/tree.cc 2023-09-18 12:36:37.598912717 +0200 > @@ -7179,6 +7179,8 @@ build_bitint_type (unsigned HOST_WIDE_IN > { > tree itype, ret; > > + gcc_checking_assert (precision >= 1 + !unsignedp); > + > if (unsignedp) > unsignedp = MAX_INT_CACHED_PREC + 1; > > @@ -11096,7 +11098,7 @@ signed_or_unsigned_type_for (int unsigne > else > return NULL_TREE; > > - if (TREE_CODE (type) == BITINT_TYPE) > + if (TREE_CODE (type) == BITINT_TYPE && (unsignedp || bits > 1)) > return build_bitint_type (bits, unsignedp); > return build_nonstandard_integer_type (bits, unsignedp); > } > --- gcc/c-family/c-common.cc.jj 2023-09-11 17:01:17.517715431 +0200 > +++ gcc/c-family/c-common.cc 2023-09-18 12:35:06.829126858 +0200 > @@ -2739,7 +2739,9 @@ c_common_signed_or_unsigned_type (int un > || TYPE_UNSIGNED (type) == unsignedp) > return type; > > - if (TREE_CODE (type) == BITINT_TYPE) > + if (TREE_CODE (type) == BITINT_TYPE > + /* signed _BitInt(1) is invalid, avoid creating that. */ > + && (unsignedp || TYPE_PRECISION (type) > 1)) > return build_bitint_type (TYPE_PRECISION (type), unsignedp); > > #define TYPE_OK(node) \ > > > Jakub > >
--- gcc/tree.cc.jj 2023-09-11 17:01:17.612714178 +0200 +++ gcc/tree.cc 2023-09-18 12:36:37.598912717 +0200 @@ -7179,6 +7179,8 @@ build_bitint_type (unsigned HOST_WIDE_IN { tree itype, ret; + gcc_checking_assert (precision >= 1 + !unsignedp); + if (unsignedp) unsignedp = MAX_INT_CACHED_PREC + 1; @@ -11096,7 +11098,7 @@ signed_or_unsigned_type_for (int unsigne else return NULL_TREE; - if (TREE_CODE (type) == BITINT_TYPE) + if (TREE_CODE (type) == BITINT_TYPE && (unsignedp || bits > 1)) return build_bitint_type (bits, unsignedp); return build_nonstandard_integer_type (bits, unsignedp); } --- gcc/c-family/c-common.cc.jj 2023-09-11 17:01:17.517715431 +0200 +++ gcc/c-family/c-common.cc 2023-09-18 12:35:06.829126858 +0200 @@ -2739,7 +2739,9 @@ c_common_signed_or_unsigned_type (int un || TYPE_UNSIGNED (type) == unsignedp) return type; - if (TREE_CODE (type) == BITINT_TYPE) + if (TREE_CODE (type) == BITINT_TYPE + /* signed _BitInt(1) is invalid, avoid creating that. */ + && (unsignedp || TYPE_PRECISION (type) > 1)) return build_bitint_type (TYPE_PRECISION (type), unsignedp); #define TYPE_OK(node) \