From patchwork Thu Feb 2 17:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 52102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp375960wrn; Thu, 2 Feb 2023 09:39:33 -0800 (PST) X-Google-Smtp-Source: AK7set+lj00gzBKyKbEhrNic1BuXyA5/fTCUNL0Xh7l2AqyK8Raj29gfqyt7oJQ7shNO0L8leCRy X-Received: by 2002:a05:6402:2742:b0:4a2:3371:cb82 with SMTP id z2-20020a056402274200b004a23371cb82mr9848056edd.18.1675359573105; Thu, 02 Feb 2023 09:39:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675359573; cv=none; d=google.com; s=arc-20160816; b=hApl9/+gkq5jYQptuqS1OXmsqmlG+x2S2o5j8TRbm+/U9p+25cl88xnJ9BHFieDI++ RIxbEubZfl3bCpdq/KPinuUowCL+D2pw4ahmPWVjJ/YkA4w7Zlxzl4htX3hQ1tOVTKGg YDMTqe+WNzdJBPtBlmgVDFqXRFKZtbA+x6Mrry6G/amBWicD12BbZU/7Cz7vJK8tcXgz VAzYTOSwu2aHb8jAqIeezLwauv/ZWwvSlLf0zFwy3HKy+WBR9g9h6hnR2sfZhZPzroLx h1hW/hgVS0rsP4KrcQ43aStUPc0v+ACHFIEpNGpwAT6k4Bds+EnwBnQfTvcccds9IKvs PD9g== 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:mime-version:mail-followup-to:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=UlcTGjlCrhbU9i5mPkcDLwJXrJCYpamXMX1SlytV73A=; b=ebEltIB24JY3Dbf4+zNFdbQdC0yYLR5XJtUaI4OxNlvTugAl0BN9tn7uIR8rBz4CBl 3OPLgn2eDYPnzIM2Dvf//ff2LoXuTJhZfVMwoTHAqBZdVgs3kU7XXginCTefsuZoDKDa CVlZG9Jkk44nEZdmYdYl8LGxCR4PzToaTvMvL/v+uPaFM6fT9uGXjcZVbbq9E6P9vEFH DuHswLZvFXYW1AKhjxG79GBOFSHsOb9rrSIabROQjT9n65mhVOmvXsVkm9jLa9OhlRlg s8+SB2uqrFy2sACwy6Su1kbovumLVxJN437dSf8apB/UxlgFOTMuvongDFlATrBsJtVS DZ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qUwMPNNT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j22-20020aa7c416000000b004614f376c2fsi13365edq.88.2023.02.02.09.39.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 09:39:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qUwMPNNT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 5443E385B539 for ; Thu, 2 Feb 2023 17:39:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5443E385B539 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675359563; bh=UlcTGjlCrhbU9i5mPkcDLwJXrJCYpamXMX1SlytV73A=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qUwMPNNThNwRxJS5evU0UNyYfOu1eX7DRw5Y/Eja23XMfgp24njp60DMzOfGLERMx Hm9zdY4XMGedFek9rH7617vozH5iwQMt3PVrIytfYNAqtBD7KmMiRGU5QJ0tWC2xlI 71xTEX+0Cnc0qV81j4FakXJtccjTplTGILE7APiY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 73C6C3858C52 for ; Thu, 2 Feb 2023 17:38:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73C6C3858C52 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 312HK57M029084; Thu, 2 Feb 2023 17:38:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nghg0rc7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Feb 2023 17:38:35 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 312HTR8x019255; Thu, 2 Feb 2023 17:38:35 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nghg0rc7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Feb 2023 17:38:35 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 312FTKhd019328; Thu, 2 Feb 2023 17:38:34 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([9.208.129.119]) by ppma02dal.us.ibm.com (PPS) with ESMTPS id 3ncvur3re0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Feb 2023 17:38:34 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 312HcW7Z35062036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2023 17:38:32 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 558FA58052; Thu, 2 Feb 2023 17:38:32 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C82E95804E; Thu, 2 Feb 2023 17:38:31 +0000 (GMT) Received: from toto.the-meissners.org (unknown [9.65.233.34]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTPS; Thu, 2 Feb 2023 17:38:31 +0000 (GMT) Date: Thu, 2 Feb 2023 12:38:30 -0500 To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner , Will Schmidt Subject: [PATCH] Bump up precision size to 16 bits. Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner , Will Schmidt MIME-Version: 1.0 Content-Disposition: inline X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Xm67nvqLmK_qRJhPfDJ7-GG7grfxRXYq X-Proofpoint-GUID: hTp5ytm7SkoabnPrc4hKvyoIH0gd4a24 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-02_12,2023-02-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 adultscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302020152 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Michael Meissner via Gcc-patches From: Michael Meissner Reply-To: Michael Meissner Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756741840118140186?= X-GMAIL-MSGID: =?utf-8?q?1756741840118140186?= The new __dmr type that is being added as a possible future PowerPC instruction set bumps into a structure field size issue. The size of the __dmr type is 1024 bits. The precision field in tree_type_common is currently 10 bits, so if you store 1,024 into field, you get a 0 back. When you get 0 in the precision field, the ccp pass passes this 0 to sext_hwi in hwint.h. That function in turn generates a shift that is equal to the host wide int bit size, which is undefined as machine dependent for shifting in C/C++. int shift = HOST_BITS_PER_WIDE_INT - prec; return ((HOST_WIDE_INT) ((unsigned HOST_WIDE_INT) src << shift)) >> shift; It turns out the x86_64 where I first did my tests returns the original input before the two shifts, while the PowerPC always returns 0. In the ccp pass, the original input is -1, and so it worked. When I did the runs on the PowerPC, the result was 0, which ultimately led to the failure. In addition, once the precision field is larger, it will help PR C/102989 (C2x _BigInt) as well as the implementation of the SET_TYPE_VECTOR_SUBPARTS macro. I bootstraped various PowerPC compilers (power10 LE, power9 LE, power8 BE) along with an x86_64 build. There were no regressions. My proposed patches for the __dmr type now run fine. Can I install this into the master branch for GCC 13? 2023-02-02 Richard Biener Michael Meissner gcc/ PR middle-end/108623 * hwint.h (sext_hwi): Add assertion against precision 0. * tree-core.h (tree_type_common): Bump up precision field to 16 bits. Align bit fields > 1 bit to at least an 8-bit boundary. --- gcc/hwint.h | 1 + gcc/tree-core.h | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gcc/hwint.h b/gcc/hwint.h index e31aa006fa4..ba92efbfc25 100644 --- a/gcc/hwint.h +++ b/gcc/hwint.h @@ -277,6 +277,7 @@ ctz_or_zero (unsigned HOST_WIDE_INT x) static inline HOST_WIDE_INT sext_hwi (HOST_WIDE_INT src, unsigned int prec) { + gcc_checking_assert (prec != 0); if (prec == HOST_BITS_PER_WIDE_INT) return src; else diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 8124a1328d4..b71748c6c02 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1686,18 +1686,8 @@ struct GTY(()) tree_type_common { tree attributes; unsigned int uid; - unsigned int precision : 10; - unsigned no_force_blk_flag : 1; - unsigned needs_constructing_flag : 1; - unsigned transparent_aggr_flag : 1; - unsigned restrict_flag : 1; - unsigned contains_placeholder_bits : 2; - + unsigned int precision : 16; ENUM_BITFIELD(machine_mode) mode : 8; - - /* TYPE_STRING_FLAG for INTEGER_TYPE and ARRAY_TYPE. - TYPE_CXX_ODR_P for RECORD_TYPE and UNION_TYPE. */ - unsigned string_flag : 1; unsigned lang_flag_0 : 1; unsigned lang_flag_1 : 1; unsigned lang_flag_2 : 1; @@ -1713,12 +1703,22 @@ struct GTY(()) tree_type_common { so we need to store the value 32 (not 31, as we need the zero as well), hence six bits. */ unsigned align : 6; + /* TYPE_STRING_FLAG for INTEGER_TYPE and ARRAY_TYPE. + TYPE_CXX_ODR_P for RECORD_TYPE and UNION_TYPE. */ + unsigned string_flag : 1; + unsigned no_force_blk_flag : 1; + unsigned warn_if_not_align : 6; + unsigned needs_constructing_flag : 1; + unsigned transparent_aggr_flag : 1; + + unsigned contains_placeholder_bits : 2; + unsigned restrict_flag : 1; unsigned typeless_storage : 1; unsigned empty_flag : 1; unsigned indivisible_p : 1; unsigned no_named_args_stdarg_p : 1; - unsigned spare : 15; + unsigned spare : 9; alias_set_type alias_set; tree pointer_to;