From patchwork Thu Jul 28 04:48:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp40506pxt; Wed, 27 Jul 2022 21:49:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vNutUHZI1svY5qyOwkJo96OgNnS8rZ/rSTpz7Qe0CIHvOPHYb4itgiQ1hbHo505+SB4nHP X-Received: by 2002:a17:907:60c6:b0:72f:2e3b:ead6 with SMTP id hv6-20020a17090760c600b0072f2e3bead6mr20060261ejc.664.1658983783522; Wed, 27 Jul 2022 21:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658983783; cv=none; d=google.com; s=arc-20160816; b=LJpkP2YmXN8zDtlm5eZIWXsXDoScCNwAO4Jd1QjdG9A88dzE/zSlQAIPaReXjVXvsM sLywn3Bs7evG1Zmx97i7X9zYvAPKFC1fMv5gJH2+NrgtBVgPY1U0wCzI56pgzRv2RpU9 sVf9N1hHrOj7YSayVZ7UraHcp94Kfd2x3pXb3G/0o/asmaBOIbyB/1d+WCEXiPnueJ5o xFG17jyxbYS2Cp9JRVepvo0d7nw+xxh0NONnC6igTHL42ZNibbG5rI6c34mhDQifZiJm KRsj5Ripx7pVFTFiU5MaLlkVNeaaJn8QC3lZtA19qtQSSqmlmYit+7Xd3YlnDb5q3d1Z 3IdQ== 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:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=7Kqwtyg7+lbPZy9CX2IEQwOWJk76emNmrVlly9L9tE0=; b=Jhgz3Gd4peCCBsDeAOU/cYALcdgTYFvt+anC+F+C12hhZ5/sfYgFT8vUvD/7Kg5CKQ dK3fLSo27N6FZLIM1wC9KLmxZ2OkKcvCxTR/gFV4kFJvTVKz0ZyGYAK7Ixk/UMiUjHZ9 NubP0y0rVVSF6fZ2XEbTPL106SBJr2tiYJZ9Bbb2t5flrb0aqJGaN7xi3DBBipSLt8sV vf57bDdYdjFGWXadKoO12xSS0CipH7L3B+eiqPJTfYakq2JiST+S3WdTmBxfnVh/xGw9 9VuPoRYSJNY+wLpWzPjS+mX0mw6cB8WOrGEezqkUWs3jeRXqJqns3gPSi1QMQm5nxXJH 8rRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=c9TmYplh; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e13-20020a056402330d00b0043ccca8012fsi12166eda.373.2022.07.27.21.49.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 21:49:43 -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=c9TmYplh; 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 150BA3858015 for ; Thu, 28 Jul 2022 04:49:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 150BA3858015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658983782; bh=7Kqwtyg7+lbPZy9CX2IEQwOWJk76emNmrVlly9L9tE0=; 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=c9TmYplhqtrNKE7BrgIRp+xfxgFmyjkAgt3REfvsL8ZVSCu/t/trzlTlRbOHJsvDl 4cU0GgNEdI4+A5wpeMWB85tgdJwZAqedFrMBMBSY666AAf8mrG2jFBEPftbv2o+xGX HTKlonA4WY7cLsJTqBVIQ6N/QUzeqmHT5I+Q0g1o= 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 5E3843858295 for ; Thu, 28 Jul 2022 04:48:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E3843858295 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26S4ljgA010795; Thu, 28 Jul 2022 04:48:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hkkra80gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 04:48:55 +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 26S4mtwO013114; Thu, 28 Jul 2022 04:48:55 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hkkra80gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 04:48:55 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26S4JmeV002964; Thu, 28 Jul 2022 04:48:54 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03dal.us.ibm.com with ESMTP id 3hg978vnrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 04:48:54 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26S4mr3n39190938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jul 2022 04:48:53 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39B26BE051; Thu, 28 Jul 2022 04:48:53 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DD2EBE04F; Thu, 28 Jul 2022 04:48:52 +0000 (GMT) Received: from toto.the-meissners.org (unknown [9.65.225.181]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTPS; Thu, 28 Jul 2022 04:48:52 +0000 (GMT) Date: Thu, 28 Jul 2022 00:48:51 -0400 To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner , Will Schmidt Subject: [PATCH 2/5] Support IEEE 128-bit overload round_to_odd built-in functions. 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-ORIG-GUID: 6fPbpLOxXSkOmwKWsimoAE8i8HufMqQ3 X-Proofpoint-GUID: BSN0Lo_xjrW7Mn0bnChi0t4fY-KAVOpw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-27_08,2022-07-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207280019 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, RCVD_IN_MSPIKE_H2, 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?1739570580212408542?= X-GMAIL-MSGID: =?utf-8?q?1739570580212408542?= [PATCH 2/5] Support IEEE 128-bit overload round_to_odd built-in functions. This patch adds support for overloading the IEEE 128-bit round to odd built-in functions bewteeen KFmode and TFmode arguments. I have tested these patches on a power10 that is running Fedora 36, which defaults to using long doubles that are IEEE 128-bit. I have built two parallel GCC compilers, one that defaults to using IEEE 128-bit long doubles and one that defaults to using IBM 128-bit long doubles. I have compared the test results to the original compiler results, comparing a modified GCC to the original compiler using an IEEE 128-bit long double default, and also comparing a modified GCC to the original compiler using an IBM 128-bit long double default. In both cases, the results are the same. I have also compared the compilers with the future patch in progress that does switch the internal type handling. Once those patches are installed, the overload mechanism will insure the correct built-in is used. Can I install this patch to the trunk, assuming I have installed the first patch in the series? 2022-07-27 Michael Meissner gcc/ * config/rs6000/rs6000-builtins.def (__builtin_addf128_round_to_odd_kf): Rename KFmode round to odd built-in functions with a KF suffix to allow overloading. (__builtin_divf128_round_to_odd_kf): Likewise. (__builtin_fmaf128_round_to_odd_kf): Likewise. (__builtin_mulf128_round_to_odd_kf): Likewise. (__builtin_sqrtf128_round_to_odd_kf): Likewise. (__builtin_subf128_round_to_odd_kf): Likewise. (__builtin_truncf128_round_to_odd_kf): Likewise. (__builtin_addf128_round_to_odd_tf): Add TFmode round to odd built-in functions. (__builtin_fmaf128_round_to_odd_tf): Likewise. (__builtin_mulf128_round_to_odd_tf): Likewise. (__builtin_sqrtf128_round_to_odd_tf): Likewise. (__builtin_subf128_round_to_odd_tf): Likewise. (__builtin_truncf128_round_to_odd_tf): Likewise. * config/rs6000/rs6000-overload.def (__builtin_addf128_round_to_odd): Make IEEE 128-bit round to odd built-in functions overloaded. (__builtin_divf128_round_to_odd): Likewise. (__builtin_fmaf128_round_to_odd): Likewise. (__builtin_mulf128_round_to_odd): Likewise. (__builtin_sqrtf128_round_to_odd): Likewise. (__builtin_subf128_round_to_odd): Likewise. (__builtin_truncf128_round_to_odd): Likewise. --- gcc/config/rs6000/rs6000-builtins.def | 58 ++++++++++++++++++++------- gcc/config/rs6000/rs6000-overload.def | 44 ++++++++++++++++++++ 2 files changed, 87 insertions(+), 15 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index defd7e25ffe..d72ff8cb7fe 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -2867,18 +2867,18 @@ ; Builtins requiring hardware support for IEEE-128 floating-point. [ieee128-hw] - fpmath _Float128 __builtin_addf128_round_to_odd (_Float128, _Float128); - ADDF128_ODD addkf3_odd {} + fpmath _Float128 __builtin_addf128_round_to_odd_kf (_Float128, _Float128); + ADDF128_ODD_KF addkf3_odd {} - fpmath _Float128 __builtin_divf128_round_to_odd (_Float128, _Float128); - DIVF128_ODD divkf3_odd {} + fpmath _Float128 __builtin_divf128_round_to_odd_kf (_Float128, _Float128); + DIVF128_ODD_KF divkf3_odd {} - fpmath _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, \ - _Float128); - FMAF128_ODD fmakf4_odd {} + fpmath _Float128 __builtin_fmaf128_round_to_odd_kf (_Float128, _Float128, \ + _Float128); + FMAF128_ODD_KF fmakf4_odd {} - fpmath _Float128 __builtin_mulf128_round_to_odd (_Float128, _Float128); - MULF128_ODD mulkf3_odd {} + fpmath _Float128 __builtin_mulf128_round_to_odd_kf (_Float128, _Float128); + MULF128_ODD_KF mulkf3_odd {} const signed int __builtin_vsx_scalar_cmp_exp_qp_eq (_Float128, _Float128); VSCEQPEQ xscmpexpqp_eq_kf {} @@ -2893,14 +2893,14 @@ __builtin_vsx_scalar_cmp_exp_qp_unordered (_Float128, _Float128); VSCEQPUO xscmpexpqp_unordered_kf {} - fpmath _Float128 __builtin_sqrtf128_round_to_odd (_Float128); - SQRTF128_ODD sqrtkf2_odd {} + fpmath _Float128 __builtin_sqrtf128_round_to_odd_kf (_Float128); + SQRTF128_ODD_KF sqrtkf2_odd {} - fpmath _Float128 __builtin_subf128_round_to_odd (_Float128, _Float128); - SUBF128_ODD subkf3_odd {} + fpmath _Float128 __builtin_subf128_round_to_odd_kf (_Float128, _Float128); + SUBF128_ODD_KF subkf3_odd {} - fpmath double __builtin_truncf128_round_to_odd (_Float128); - TRUNCF128_ODD trunckfdf2_odd {} + fpmath double __builtin_truncf128_round_to_odd_kf (_Float128); + TRUNCF128_ODD_KF trunckfdf2_odd {} const signed long long __builtin_vsx_scalar_extract_expq (_Float128); VSEEQP xsxexpqp_kf {} @@ -2924,6 +2924,34 @@ VSTDCNQP xststdcnegqp_kf {} +; Builtins requiring hardware support for IEEE-128 floating-point. Long double +; must use the IEEE 128-bit encoding. +[ieee128-hw-ld] + fpmath long double __builtin_addf128_round_to_odd_tf (long double, long double); + ADDF128_ODD_TF addtf3_odd {ieeeld} + + fpmath long double __builtin_divf128_round_to_odd_tf (long double,long double); + DIVF128_ODD_TF divtf3_odd {ieeeld} + + fpmath long double __builtin_fmaf128_round_to_odd_tf (long double, \ + long double, \ + long double); + FMAF128_ODD_TF fmatf4_odd {ieeeld} + + fpmath long double __builtin_mulf128_round_to_odd_tf (long double, \ + long double); + MULF128_ODD_TF multf3_odd {ieeeld} + + fpmath long double __builtin_sqrtf128_round_to_odd_tf (long double); + SQRTF128_ODD_TF sqrttf2_odd {ieeeld} + + fpmath long double __builtin_subf128_round_to_odd_tf (long double, \ + long double); + SUBF128_ODD_TF subtf3_odd {ieeeld} + + fpmath double __builtin_truncf128_round_to_odd_tf (long double); + TRUNCF128_ODD_TF trunctfdf2_odd {ieeeld} + ; Decimal floating-point builtins. [dfp] diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index 44e2945aaa0..f406a16a882 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -6175,3 +6175,47 @@ VUPKLSW VUPKLSW_DEPR1 vbll __builtin_vec_vupklsw (vbi); VUPKLSW VUPKLSW_DEPR2 + +[ADDF128_ODD, SKIP, __builtin_addf128_round_to_odd] + long double __builtin_addf128_round_to_odd (long double, long double); + ADDF128_ODD_TF + _Float128 __builtin_addf128_round_to_odd (_Float128, _Float128); + ADDF128_ODD_KF + +[DIVF128_ODD, SKIP, __builtin_divf128_round_to_odd] + long double __builtin_divf128_round_to_odd (long double, long double); + DIVF128_ODD_TF + _Float128 __builtin_divf128_round_to_odd (_Float128, _Float128); + DIVF128_ODD_KF + +[FMAF128_ODD, SKIP, __builtin_fmaf128_round_to_odd] + long double __builtin_fmaf128_round_to_odd (long double, long double, \ + long double); + FMAF128_ODD_TF + _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, \ + _Float128); + FMAF128_ODD_KF + +[MULF128_ODD, SKIP, __builtin_mulf128_round_to_odd] + long double __builtin_mulf128_round_to_odd (long double, long double); + MULF128_ODD_TF + _Float128 __builtin_mulf128_round_to_odd (_Float128, _Float128); + MULF128_ODD_KF + +[SQRTF128_ODD, SKIP, __builtin_sqrtf128_round_to_odd] + long double __builtin_sqrtf128_round_to_odd (long double); + SQRTF128_ODD_TF + _Float128 __builtin_sqrtf128_round_to_odd (_Float128); + SQRTF128_ODD_KF + +[SUBF128_ODD, SKIP, __builtin_subf128_round_to_odd] + long double __builtin_subf128_round_to_odd (long double, long double); + SUBF128_ODD_TF + _Float128 __builtin_subf128_round_to_odd (_Float128, _Float128); + SUBF128_ODD_KF + +[TRUNCF128_ODD, SKIP, __builtin_truncf128_round_to_odd] + long double __builtin_truncf128_round_to_odd (long double); + TRUNCF128_ODD_TF + _Float128 __builtin_truncf128_round_to_odd (_Float128); + TRUNCF128_ODD_KF