From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 7A1AA3858D28 for ; Mon, 12 Jun 2023 06:51:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A1AA3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35C6MUkW029274; Mon, 12 Jun 2023 06:51:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=vWtxSxWD9/RZsd8xZ7zgPLYBf9qIaLfL2bVnMbN4tr0=; b=aFSFReiSPVXZrAIdEcnGnb3rGmIiREZuAhfAXTm9Y2W5r0s+umZAa5FaFkkUPsesmEr5 X4GDfzmEWN+z/8j35VRw7CVGxG/sK0MkBCM8dLqFBZRuuUQYJwNekmJz1q2HfEqNDRxC hVTrFKIsE0zvtUsRDWKO6aq9Py6qtSSeNnpWqcjnVw3txirTbxmp3A53RKi/n0HEEALI xqrX9E6Qrpib/PeFVKd7XLkajimGvFRrPWwvp7R6I30cKN0dEi9PQUI2x/h83tb9IGLR 5nL4cSRHRmYto4LxQFIa3agik+m4vUD2m0spFXM98RqQd31javTmLYohk8OpuRY3/qT8 ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r5x1r0mb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 06:51:16 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35C6SFwW012767; Mon, 12 Jun 2023 06:51:15 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r5x1r0maf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 06:51:15 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35C3vCXR028434; Mon, 12 Jun 2023 06:51:13 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3r4gee1ajn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jun 2023 06:51:13 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35C6pAgr42336624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 06:51:11 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E18FB20043; Mon, 12 Jun 2023 06:51:10 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E27FF20040; Mon, 12 Jun 2023 06:51:08 +0000 (GMT) Received: from [9.177.2.98] (unknown [9.177.2.98]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 12 Jun 2023 06:51:08 +0000 (GMT) Message-ID: <138a8f9d-eca9-1885-38b0-255337986489@linux.ibm.com> Date: Mon, 12 Jun 2023 14:51:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] rs6000: Don't use TFmode for 128 bits fp constant in toc [PR110011] Content-Language: en-US To: David Edelsohn Cc: GCC Patches , Segher Boessenkool , Peter Bergner References: From: "Kewen.Lin" In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: IFA1gzVcnAEuAHSRd8Pf9Y96T4jF07br X-Proofpoint-ORIG-GUID: H3vXMaTYtK1brCJGYDMlP7RAWpRRKHTe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-12_04,2023-06-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 bulkscore=0 adultscore=0 malwarescore=0 impostorscore=0 mlxscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120057 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,NICE_REPLY_A,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 List-Id: on 2023/6/11 10:04, David Edelsohn wrote: > On Tue, Jun 6, 2023 at 5: 20 AM Kewen. Lin wrote: 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 > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > This message came from outside your organization. >   > ZjQcmQRYFpfptBannerEnd > On Tue, Jun 6, 2023 at 5:20 AM Kewen.Lin > wrote: > > 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. > > > The comment wording can be worded better.  Maybe  > > Use the mode of the 128-bit floating constant itself for real_to_target call. > > This is okay. Thanks David, I've updated changelog as you suggested and pushed as r14-1703. Will backport after burn-in time. BR, Kewen > > Thanks, David > > > 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 > > 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; > +} > + > -- > 2.31.1 >