From patchwork Tue Jun 6 09:20:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 103681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3258044vqr; Tue, 6 Jun 2023 02:21:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rc9sgREzAV4Hrr5ekNI0bQrcFot7uCyLvErHFALDcWXNxEKJA4nbBgexsM2et+wnXemEr X-Received: by 2002:a17:906:9b96:b0:978:6e73:e841 with SMTP id dd22-20020a1709069b9600b009786e73e841mr1455653ejc.35.1686043265574; Tue, 06 Jun 2023 02:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686043265; cv=none; d=google.com; s=arc-20160816; b=Sv+a0MqQktizg4FuonURhhZ62R3+LEc1a72mjMDMg5FwixBzygyByYECVFYf7p/qBx Z2ylSS4P1Ax6YJQRY7AI8yNnA0ICjTA7eV9oe9IAntbUIBfN/TgIi4IrUc3W040suwBe VQTC6e66vUPFCiPQng+LrTE0Uq/VcW9fZg9gucFXhRMPYBsY2OjzymC1eayNqGK0shwv 5uRDj8tuI9hCaGioh2dlhpJSCTFjeZp5I7ba+QmmUWTcFQ2DW5xYchXRsJmSjOKigbrS 8DuUC0xLyokV2df+z+BB4V0Z5WBYc9P2XXj31KeQSI8t38YEPoqv6Cs+JyXnULT8oks1 dCgg== 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-transfer-encoding:cc:to:subject:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=OHH/TCYrWzASDT3EMeVu+BfhOI/SaCwezD39MLy4hrk=; b=yEdL6JEdOCOGt3GQJLm0efYPze39AwH+thy/5A4UgEA7basa48dOfBAZTIRffthPAC B8jXv1ek5RQ3zdN1JAzjxJrzlV4bu6/Beb0YTQfk6mCCfMyX5VGcCHKZSq3PqQ5aGWON pRYC6vsPb3LiMaxO3EeOCx8h/xWXUXHqcOc1oDC9L+1idf2OAUNywupGo/NwyYeteJg0 Z4LTtWOQRSGBqQ9va1sUFZxAAJfmtvhI++3SRNUSBudloxWAL7FoQNPYkAK1lLJTpRPt s4U28/CdGDV1+Qbq2Qj0wr808zPFN56tzwGdyLDQZPISZz3WQj95A9Rm962+yoMebpOw 0khQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eXRiXNew; 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 qa36-20020a17090786a400b00977cc53e8fbsi3936417ejc.974.2023.06.06.02.21.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:21:05 -0700 (PDT) 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=eXRiXNew; 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 24F6A3858000 for ; Tue, 6 Jun 2023 09:21:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24F6A3858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686043264; bh=OHH/TCYrWzASDT3EMeVu+BfhOI/SaCwezD39MLy4hrk=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=eXRiXNewNT+mPKBU6+ZwB3bQmfl0z5u8pfqMEDV9hO/2nFo74hDuTssIW5pXA2Foa +gYBM0jH18Y5isB7pOQYLYvzBlp3V7w02Pcdm8U8kidITXFDbZ7ERh7izuR/sG5unV m8lRumXz7D2wy9tXGnk5fx0PSrJFDDp7ShtKpA28= 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 7CFA73858280 for ; Tue, 6 Jun 2023 09:20:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7CFA73858280 Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3569DtkC032606; Tue, 6 Jun 2023 09:20:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r2203g4fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 09:20:18 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3569EHru001637; Tue, 6 Jun 2023 09:20:17 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r2203g4en-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 09:20:17 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3565lloa017688; Tue, 6 Jun 2023 09:20:15 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3qyxbu9ff9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 09:20:14 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3569KCi145744636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Jun 2023 09:20:12 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 629A520040; Tue, 6 Jun 2023 09:20:12 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 826E520043; Tue, 6 Jun 2023 09:20:10 +0000 (GMT) Received: from [9.177.93.112] (unknown [9.177.93.112]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 6 Jun 2023 09:20:10 +0000 (GMT) Message-ID: Date: Tue, 6 Jun 2023 17:20:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US Subject: [PATCH] rs6000: Don't use TFmode for 128 bits fp constant in toc [PR110011] To: GCC Patches Cc: Segher Boessenkool , Peter Bergner , David Edelsohn X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -VikH32I-XsSIsLwycNUmM3xvv8FtOzh X-Proofpoint-GUID: FeKREVVZTj40cPkzQNCdJlnkc7bsW91L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_05,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=880 clxscore=1015 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 phishscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060078 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" 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?1767944503431492353?= X-GMAIL-MSGID: =?utf-8?q?1767944503431492353?= Hi, As PR110011 shows, when encoding 128 bits fp constant into toc, we adopts REAL_VALUE_TO_TARGET_LONG_DOUBLE which is to find the first float mode with LONG_DOUBLE_TYPE_SIZE bits of precision, it would be TFmode here. But the 128 bits fp constant can be with mode IFmode or KFmode, which doesn't necessarily have the same underlying float format as the one of TFmode, like this PR exposes, with option -mabi=ibmlongdouble TFmode has ibm_extended_format while KFmode has ieee_quad_format, mixing up the formats (the encoding/decoding ways) would cause unexpected results. This patch is to make it use constant's own mode instead of TFmode for real_to_target call. Bootstrapped and regtested on powerpc64-linux-gnu P7/P8/P9 and powerpc64le-linux-gnu P9 and P10. I'll push this next week if no objections. BR, Kewen ----- PR target/110011 gcc/ChangeLog: * config/rs6000/rs6000.cc (output_toc): Use its own mode of the 128-bit float constant for real_to_target call. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr110011.c: New test. --- gcc/config/rs6000/rs6000.cc | 2 +- gcc/testsuite/gcc.target/powerpc/pr110011.c | 42 +++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr110011.c -- 2.31.1 diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 3f129ea37d2..330c6a6fa5f 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -17314,7 +17314,7 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode) if (DECIMAL_FLOAT_MODE_P (GET_MODE (x))) REAL_VALUE_TO_TARGET_DECIMAL128 (*CONST_DOUBLE_REAL_VALUE (x), k); else - REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), k); + real_to_target (k, CONST_DOUBLE_REAL_VALUE (x), GET_MODE (x)); if (TARGET_64BIT) { diff --git a/gcc/testsuite/gcc.target/powerpc/pr110011.c b/gcc/testsuite/gcc.target/powerpc/pr110011.c new file mode 100644 index 00000000000..5b04d3e298a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr110011.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-require-effective-target float128_runtime } */ +/* Force long double to be with IBM format here, to verify + _Float128 constant still uses its own format (IEEE) for + encoding rather than IBM format. */ +/* { dg-options "-mfp-in-toc -mabi=ibmlongdouble" } */ +/* { dg-add-options float128 } */ + +#define MPFR_FLOAT128_MAX 0x1.ffffffffffffffffffffffffffffp+16383f128 + +__attribute__ ((noipa)) +_Float128 f128_max () +{ + return MPFR_FLOAT128_MAX; +} + +typedef union +{ + int w[4]; + _Float128 f128; +} U; + +int main () +{ + + U umax; + umax.f128 = f128_max (); + /* ieee float128 max: + 7ffeffff ffffffff ffffffff ffffffff. */ + if (umax.w[1] != 0xffffffff || umax.w[2] != 0xffffffff) + __builtin_abort (); +#ifdef __LITTLE_ENDIAN__ + if (umax.w[0] != 0xffffffff || umax.w[3] != 0x7ffeffff) + __builtin_abort (); +#else + if (umax.w[3] != 0xffffffff || umax.w[0] != 0x7ffeffff) + __builtin_abort (); +#endif + + return 0; +} +