From patchwork Mon Apr 11 08:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 52772 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 98F583847927 for ; Mon, 11 Apr 2022 08:27:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98F583847927 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649665675; bh=3Dth6KaU44+e1XZtCuHaIDg9I8ZUbqiaZccjXEZEXQA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CaZmiASTxSB9Sbdvx0sYvUeuchGN6cTZ1KzDnp3Ep7p73XjL2M3TKNuk6Heo+s8t9 jgZSg9oO/XELGp1W8/GEo4eUa/qROvCtpSJDPvABfoLSlGPetiQy336iFqCjfYPNqf EzO/JqBrKAVG8uVzQCJNqkeXrqXja7ddmqMHKSBs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 9C8903856DEB for ; Mon, 11 Apr 2022 08:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C8903856DEB Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23B6qeiU028389; Mon, 11 Apr 2022 08:27:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fcfev1qt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Apr 2022 08:27:22 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23B8JEl8020809; Mon, 11 Apr 2022 08:27:21 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fcfev1qsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Apr 2022 08:27:21 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23B8FQTp009855; Mon, 11 Apr 2022 08:27:19 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06fra.de.ibm.com with ESMTP id 3fbsj012mj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Apr 2022 08:27:19 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23B8RG7A52035984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Apr 2022 08:27:16 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94881A405B; Mon, 11 Apr 2022 08:27:16 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 925C5A4054; Mon, 11 Apr 2022 08:27:14 +0000 (GMT) Received: from [9.197.237.77] (unknown [9.197.237.77]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 Apr 2022 08:27:14 +0000 (GMT) Message-ID: <900ac453-f5e8-c2cb-8245-0f8b59300e48@linux.ibm.com> Date: Mon, 11 Apr 2022 16:27:12 +0800 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 To: GCC Patches Subject: [PATCH v3] rs6000: Guard bifs {un, }pack_{longdouble, ibm128} under hard float [PR103623] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pdR34cHFMFWiSiitcSIeLCyXFSJjdu-v X-Proofpoint-ORIG-GUID: BrzhBb6PP0-iTgck8tVASwh1F6XswJ_Q X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-11_02,2022-04-08_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 suspectscore=0 phishscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204110045 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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" Cc: Jakub Jelinek , Peter Bergner , David Edelsohn , Segher Boessenkool Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, As PR103623 shows, it's a regression failure due to new built-in function framework, previously we guard __builtin_{un,}pack_{longdouble, ibm128} built-in functions under hard float, so they are unavailable with the given configuration. While with new bif infrastructure, it becomes available and gets ICE due to incomplete supports. Segher and Peter pointed out that we should make it available with soft float, I agree we can extend it to cover both soft and hard float. But considering it's stage 4 now and this regression is classified as P1, also the previous behavior requiring hard float aligns with what document [1] says, I think it may be a good idea to fix it with a small patch to be consistent with the previous behavior. Then we can extend the functionality by being tracked in new PR105213 for GCC13. Re-bootstrapped and re-tested as before. v1: https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591147.html v2: Add one more test case. https://gcc.gnu.org/pipermail/gcc-patches/2022-April/592981.html v3: Add FIXME as Segher suggested. [1] https://gcc.gnu.org/onlinedocs/gcc/Basic-PowerPC-Built-in-Functions-Available-on-ISA-2_002e05.html#Basic-PowerPC-Built-in-Functions-Available-on-ISA-2_002e05 BR, Kewen ----- PR target/103623 gcc/ChangeLog: * config/rs6000/rs6000-builtins.def (__builtin_pack_longdouble): Add nosoft attribute. (__builtin_unpack_longdouble): Likewise. (__builtin_pack_ibm128): Likewise. (__builtin_unpack_ibm128): Likewise. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr103623.c: New test. --- gcc/config/rs6000/rs6000-builtins.def | 12 ++++-- gcc/testsuite/gcc.target/powerpc/pr103623.c | 47 +++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr103623.c -- 2.27.0 diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 0f527c5d78f..9170de35874 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -220,7 +220,8 @@ ; This is redundant with __builtin_pack_ibm128, as it requires long ; double to be __ibm128. Should probably be deprecated. const long double __builtin_pack_longdouble (double, double); - PACK_TF packtf {ibmld} +; FIXME: Make this available for soft-float, see PR105213. + PACK_TF packtf {ibmld,nosoft} unsigned long __builtin_ppc_mftb (); MFTB rs6000_mftb_di {32bit} @@ -235,18 +236,21 @@ MTFSF rs6000_mtfsf {} const __ibm128 __builtin_pack_ibm128 (double, double); - PACK_IF packif {ibm128} +; FIXME: Make this available for soft-float, see PR105213. + PACK_IF packif {ibm128,nosoft} void __builtin_set_fpscr_rn (const int[0,3]); SET_FPSCR_RN rs6000_set_fpscr_rn {nosoft} const double __builtin_unpack_ibm128 (__ibm128, const int<1>); - UNPACK_IF unpackif {ibm128} +; FIXME: Make this available for soft-float, see PR105213. + UNPACK_IF unpackif {ibm128,nosoft} ; This is redundant with __builtin_unpack_ibm128, as it requires long ; double to be __ibm128. Should probably be deprecated. const double __builtin_unpack_longdouble (long double, const int<1>); - UNPACK_TF unpacktf {ibmld} +; FIXME: Make this available for soft-float, see PR105213. + UNPACK_TF unpacktf {ibmld,nosoft} ; Builtins that have been around just about forever, but not quite. diff --git a/gcc/testsuite/gcc.target/powerpc/pr103623.c b/gcc/testsuite/gcc.target/powerpc/pr103623.c new file mode 100644 index 00000000000..701db8bafa8 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr103623.c @@ -0,0 +1,47 @@ +/* { dg-skip-if "" { powerpc*-*-darwin* } } */ +/* { dg-options "-mlong-double-128 -msoft-float" } */ + +/* Verify there is no ICE. */ + +#include +#include +#include + +#if defined(__LONG_DOUBLE_IEEE128__) +/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of + long double, and to use the appropriate pack/unpack routines. We can't use + __ibm128 on systems that don't support IEEE 128-bit floating point, because + the type is not enabled on those systems. */ +#define PACK __builtin_pack_ibm128 +#define UNPACK __builtin_unpack_ibm128 +#define LDOUBLE __ibm128 + +#elif defined(__LONG_DOUBLE_IBM128__) +#define PACK __builtin_pack_longdouble +#define UNPACK __builtin_unpack_longdouble +#define LDOUBLE long double + +#else +#error "long double must be either IBM 128-bit or IEEE 128-bit" +#endif + +extern LDOUBLE bar (LDOUBLE); + +int +main (void) +{ + double high = pow (2.0, 60); + double low = 2.0; + LDOUBLE a = ((LDOUBLE) high) + ((LDOUBLE) low); + double x0 = UNPACK (a, 0); + /* Let's ignore all error messages about built-in function + unsupported due to soft-float, since they are not test + points here (this case is to check no ICE). */ + /* { dg-excess-errors "pr103623" } */ + double x1 = UNPACK (a, 1); + LDOUBLE b = PACK (x0, x1); + LDOUBLE c = bar (b); + + return c > a; +} +