From patchwork Wed Jul 7 19:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1501999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PwF83ect; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKqxj5z0cz9sWX for ; Thu, 8 Jul 2021 05:59:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9069D385742A for ; Wed, 7 Jul 2021 19:59:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9069D385742A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1625687943; bh=qoTgGLMq7v21VueGCeqPzXG1IT6zvndylAxVFqWKicY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PwF83ect8U2DwsxbwzpW++YqRi2XVPVSd5QnUAXuqjiDJ0ufbkluwgI4RSNheJkz0 yC+0ey1xuGwpa24IRp8e2LiwLIUFDp9PWjRVbZrtL/lNeJbRCobUnqvqqOcyBMwyVX 3xynAG7G6iX0w1hhdPKXy6Boyb3gnZld85ro32xY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 7F769385742A for ; Wed, 7 Jul 2021 19:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F769385742A Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 167JXCkW068542; Wed, 7 Jul 2021 15:58:42 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 39mkpw3ngx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Jul 2021 15:58:41 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 167Jwf8h168991; Wed, 7 Jul 2021 15:58:41 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 39mkpw3ngj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Jul 2021 15:58:41 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 167Jv6bC015272; Wed, 7 Jul 2021 19:58:40 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma01wdc.us.ibm.com with ESMTP id 39jfhbvf1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Jul 2021 19:58:40 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 167JweeS36307228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Jul 2021 19:58:40 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05662B2065; Wed, 7 Jul 2021 19:58:40 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8225CB2064; Wed, 7 Jul 2021 19:58:39 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.160.9.169]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTPS; Wed, 7 Jul 2021 19:58:39 +0000 (GMT) Date: Wed, 7 Jul 2021 15:58:37 -0400 To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner , Will Schmidt Subject: Repost: [PATCH] Fix long double tests when default long double is not IBM. Message-ID: <20210707195837.GA28511@ibm-toto.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner , Will Schmidt MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fUh7tstZK4RzxP_CpqfHx3SaoFx0OtGB X-Proofpoint-GUID: J3dW3o7arjoqd0pGT6FgWRJLkqxlYqSX X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-07_09:2021-07-06, 2021-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070112 X-Spam-Status: No, score=-11.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 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: Michael Meissner via Gcc-patches From: Michael Meissner Reply-To: Michael Meissner Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" [PATCH] Fix long double tests when default long double is not IBM. This patch adds 3 more selections to target-supports.exp to see if we can force the compiler to use a particular long double format (IEEE 128-bit, IBM extended double, 64-bit), and the library support will track the changes for the long double. This is needed because two of the tests in the test suite use long double, and they are actually testing IBM extended double. This patch also forces the two tests that explicitly require long double to use the IBM double-double encoding to explicitly run the test. This requires GLIBC 2.32 or greater in order to do the switch. I have run tests on a little endian power9 system with 3 compilers. There were no regressions with these patches, and the two tests in the following patches now work if the default long double is not IBM 128-bit: * One compiler used the default IBM 128-bit format; * One compiler used the IEEE 128-bit format; (and) * One compiler used 64-bit long doubles. I have also tested compilers on a big endian power8 system with a compiler defaulting to power8 code generation and another with the default cpu set. There were no regressions. Can I check this patch into the master branch? 2021-07-07 Michael Meissner gcc/testsuite/ PR target/70117 * gcc.target/powerpc/pr70117.c: Force the long double type to use the IBM 128-bit format. * c-c++-common/dfp/convert-bfp-11.c: Force using IBM 128-bit long double. Remove check for 64-bit long double. * lib/target-supports.exp (add_options_for_ppc_long_double_override_ibm128): New function. (check_effective_target_ppc_long_double_override_ibm128): New function. (add_options_for_ppc_long_double_override_ieee128): New function. (check_effective_target_ppc_long_double_override_ieee128): New function. (add_options_for_ppc_long_double_override_64bit): New function. (check_effective_target_ppc_long_double_override_64bit): New function. --- .../c-c++-common/dfp/convert-bfp-11.c | 18 +-- gcc/testsuite/gcc.target/powerpc/pr70117.c | 6 +- gcc/testsuite/lib/target-supports.exp | 107 ++++++++++++++++++ 3 files changed, 121 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c index 95c433d2c24..35da07d1fa4 100644 --- a/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c @@ -1,9 +1,14 @@ -/* { dg-skip-if "" { ! "powerpc*-*-linux*" } } */ +/* { dg-require-effective-target dfp } */ +/* { dg-require-effective-target ppc_long_double_override_ibm128 } */ +/* { dg-add-options ppc_long_double_override_ibm128 } */ -/* Test decimal float conversions to and from IBM 128-bit long double. - Checks are skipped at runtime if long double is not 128 bits. - Don't force 128-bit long doubles because runtime support depends - on glibc. */ +/* We force the long double type to be IBM 128-bit because the CONVERT_TO_PINF + tests will fail if we use IEEE 128-bit floating point. This is due to IEEE + 128-bit having a larger exponent range than IBM 128-bit extended double. So + tests that would generate an infinity with IBM 128-bit will generate a + normal number with IEEE 128-bit. */ + +/* Test decimal float conversions to and from IBM 128-bit long double. */ #include "convert.h" @@ -36,9 +41,6 @@ CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32) int main () { - if (sizeof (long double) != 16) - return 0; - convert_101 (); convert_102 (); diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c index 3bbd2c595e0..8a5fad1dee0 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr70117.c +++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c @@ -1,5 +1,7 @@ -/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } } */ -/* { dg-options "-std=c99 -mlong-double-128 -O2" } */ +/* { dg-do run } */ +/* { dg-require-effective-target ppc_long_double_override_ibm128 } */ +/* { dg-options "-std=c99 -O2" } */ +/* { dg-add-options ppc_long_double_override_ibm128 } */ #include diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 789723fb287..0a392cb0fd5 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2360,6 +2360,113 @@ proc check_effective_target_ppc_ieee128_ok { } { }] } +# Check if we can explicitly override the long double format to use the IBM +# 128-bit extended double format, and GLIBC supports doing this override by +# switching the sprintf to handle IBM 128-bit long double. + +proc add_options_for_ppc_long_double_override_ibm128 { flags } { + if { [istarget powerpc*-*-*] } { + return "$flags -mlong-double-128 -Wno-psabi -mabi=ibmlongdouble" + } + return "$flags" +} + +proc check_effective_target_ppc_long_double_override_ibm128 { } { + return [check_runtime_nocache ppc_long_double_override_ibm128 { + #include + #include + volatile __ibm128 a = (__ibm128) 3.0; + volatile long double one = 1.0L; + volatile long double two = 2.0L; + volatile long double b; + char buffer[20]; + int main() + { + #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__) + return 1; + #else + b = one + two; + if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0) + return 1; + sprintf (buffer, "%lg", b); + return strcmp (buffer, "3") != 0; + #endif + } + } [add_options_for_ppc_long_double_override_ibm128 ""]] +} + +# Check if we can explicitly override the long double format to use the IEEE +# 128-bit format, and GLIBC supports doing this override by switching the +# sprintf to handle IEEE 128-bit long double. + +proc add_options_for_ppc_long_double_override_ieee128 { flags } { + if { [istarget powerpc*-*-*] } { + return "$flags -mlong-double-128 -Wno-psabi -mabi=ieeelongdouble" + } + return "$flags" +} + +proc check_effective_target_ppc_long_double_override_ieee128 { } { + return [check_runtime_nocache ppc_long_double_override_ieee128 { + #include + #include + volatile _Float128 a = 3.0f128; + volatile long double one = 1.0L; + volatile long double two = 2.0L; + volatile long double b; + char buffer[20]; + int main() + { + #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__) + return 1; + #else + b = one + two; + if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0) + return 1; + sprintf (buffer, "%lg", b); + return strcmp (buffer, "3") != 0; + #endif + } + } [add_options_for_ppc_long_double_override_ieee128 ""]] +} + +# Check if we can explicitly override the long double format to use 64-bit +# floating point, and GLIBC supports doing this override by switching the +# sprintf to handle 64-bit long double. + +proc add_options_for_ppc_long_double_override_64bit { flags } { + if { [istarget powerpc*-*-*] } { + return "$flags -mlong-double-64" + } + return "$flags" +} + +proc check_effective_target_ppc_long_double_override_64bit { } { + return [check_runtime_nocache ppc_long_double_override_64bit { + #include + #include + volatile double a = 3.0; + volatile long double one = 1.0L; + volatile long double two = 2.0L; + volatile long double b; + char buffer[20]; + int main() + { + #if !defined(_ARCH_PPC) || defined(__LONG_DOUBLE_128__) + return 1; + #else + if (sizeof (long double) != sizeof (double)) + return 1; + b = one + two; + if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0) + return 1; + sprintf (buffer, "%lg", b); + return strcmp (buffer, "3") != 0; + #endif + } + } [add_options_for_ppc_long_double_override_64bit ""]] +} + # Return 1 if the target supports executing VSX instructions, 0 # otherwise. Cache the result.