From patchwork Thu Aug 18 21:42:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 56865 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A78513858C2C for ; Thu, 18 Aug 2022 21:43:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A78513858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660859004; bh=pm/zQYKhy3uxwY6E6ZWZgNIfSJcCAxCkmHMitXipEko=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mGurV+K6X8RC22mHQx9SsVxhwu/WFWEWv3qQOFCcUTy6g5qRacIf+trPzRy3Y91cw Ds+UfodA7TjI1JurjxG8yTLYCirIUxyKDPAYbczUaAqF4xDFS0m0pSo7HAzJQiKVWu 7yoVXLeKjkon4uNRrGGLWO4U6XxBlLHQm9R2P7Ow= 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 B35A43858D28 for ; Thu, 18 Aug 2022 21:42:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B35A43858D28 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27ILT1pi006506; Thu, 18 Aug 2022 21:42:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j1wcpg8dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 21:42:54 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27ILaW7q032379; Thu, 18 Aug 2022 21:42:54 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j1wcpg8dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 21:42:54 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27ILKmlZ029732; Thu, 18 Aug 2022 21:42:53 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 3hx3ka18fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 21:42:53 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27ILgqRh18874778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Aug 2022 21:42:52 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 542242805A; Thu, 18 Aug 2022 21:42:52 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F93728058; Thu, 18 Aug 2022 21:42:52 +0000 (GMT) Received: from toto.the-meissners.org (unknown [9.65.225.181]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTPS; Thu, 18 Aug 2022 21:42:51 +0000 (GMT) Date: Thu, 18 Aug 2022 17:42:50 -0400 To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner , Will Schmidt Subject: [PATCH 3/3] Add 'w' suffix for __ibm128 constants Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner , Will Schmidt References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Ab3CIhra0vL_1PZyUwHsPd29AzLWT3-N X-Proofpoint-ORIG-GUID: R6azdIqTnPTq7RYEIYfDLVMy-6ZHtxC9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-18_16,2022-08-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208180077 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, KAM_SHORT, RCVD_IN_MSPIKE_H2, 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 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Add 'w' suffix for __ibm128 constants. In the documentation, we mention that 'w' or 'W' can be used as a suffix for __ibm128 constants. We never implemented this. This patch fixes that. In addition, the 'q' and 'Q' suffix were changed to use the mode used for the __float128 type, instead of knowing whether to use KFmode or TFmode explicitly. This will be used in a future patch where we change the mode used for __float128 on systems where long double is IEEE 128-bit. I have tested this patch on the following systems: 1) LE Power10 using --with-cpu=power10 --with-long-double-format=ieee 2) LE Power10 using --with-cpu=power9 --with-long-double-format=ibm 3) LE Power10 using --with-cpu=power8 --with-long-double-format=ibm 4) LE Power10 using --with-cpu=power10 --with-long-double-format=ibm 5) LE Power9 using --with-cpu=power9 --with-long-double-format=ibm 6) BE Power8 using --with-cpu=power8 --with-long-double-format=ibm 7) BE Power8 using --with-cpu=power5 --with-long-double-format=ibm There were no regressions in the build or in the tests. Can I check this patch into the trunk? Did we want to backport this to earlier GCC releases? 2022-08-17 Michael Meissner gcc/ * config/rs6000/rs6000.cc (rs6000_c_mode_for_suffix): Allow 'w' or 'W' for __ibm128 constants. gcc/testsuite/ * gcc.target/powerpc/ibm128-suffix.c: New test. --- gcc/config/rs6000/rs6000.cc | 25 ++++++++++--------- .../gcc.target/powerpc/ibm128-suffix.c | 13 ++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index a6ec4c71ac0..046c538c748 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -23845,22 +23845,23 @@ rs6000_floatn_mode (int n, bool extended) } -/* Target hook for c_mode_for_suffix. */ +/* Target hook for c_mode_for_suffix. We use TYPE_MODE to follow the mode used + for __float128 and __ibm128. + + Only two suffixes are allowed, 'q' and 'w'. The 'q' suffix is used for + float128 constants on both the x86 and PowerPC processors. Its use predates + the use of 'f128' for _Float128 constants, and existing code still uses it. + + The 'w' suffix was used on the x86 processors for their 80-bit long + double. We use it for __ibm128 constants. */ static machine_mode rs6000_c_mode_for_suffix (char suffix) { - if (TARGET_FLOAT128_TYPE) - { - if (suffix == 'q' || suffix == 'Q') - return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; + if (TARGET_FLOAT128_TYPE && (suffix == 'q' || suffix == 'Q')) + return TYPE_MODE (ieee128_float_type_node); - /* At the moment, we are not defining a suffix for IBM extended double. - If/when the default for -mabi=ieeelongdouble is changed, and we want - to support __ibm128 constants in legacy library code, we may need to - re-evalaute this decision. Currently, c-lex.cc only supports 'w' and - 'q' as machine dependent suffixes. The x86_64 port uses 'w' for - __float80 constants. */ - } + if (TARGET_IBM128 && (suffix == 'w' || suffix == 'W')) + return TYPE_MODE (ibm128_float_type_node); return VOIDmode; } diff --git a/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c b/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c new file mode 100644 index 00000000000..ff619860409 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target longdouble128 } */ +/* { dg-options "-O2" } */ + +/* See if the 'w' suffix is accepted for __ibm128. */ +#ifndef NUMBER +#define NUMBER 123456789012345678901234567890123456789E-10 +#endif + +#define GLUE2(X,Y) X ## Y +#define GLUE(X,Y) GLUE2(X,Y) + +__ibm128 x = GLUE (NUMBER, w);