From patchwork Sat Jan 29 03:47:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 50563 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 C1698385842B for ; Sat, 29 Jan 2022 03:47:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1698385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643428065; bh=ZFlBeOd7Yu/VLFZIDf+nB0WHDd9vnzYn0zYbCmA33wk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=i3d/dwCVYN1RkEhaVJgCCyAfQNjwgljVGq32Hh2tRl1LQE4MggfXzuwtuvqApjDJj zjnmaXXLASk/aZUGuU2IO8u+SbVi+7jBPclehbMMDfFMPopl1HBtj6fs3htIFzsfsb M5oI5K1wB9pnveUU2Ts3qLk8gKTt1P1RKSb1vOMg= 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 BB972385840C for ; Sat, 29 Jan 2022 03:47:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BB972385840C Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20T3ZpXY021040; Sat, 29 Jan 2022 03:47:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dvv73975q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 29 Jan 2022 03:47:14 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20T3lEiO022191; Sat, 29 Jan 2022 03:47:14 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dvv73975h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 29 Jan 2022 03:47:14 +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 20T3g5nc025350; Sat, 29 Jan 2022 03:47:13 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma03dal.us.ibm.com with ESMTP id 3dvw75rebp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 29 Jan 2022 03:47:13 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20T3l8LU35848532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 29 Jan 2022 03:47:08 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B00A11206B; Sat, 29 Jan 2022 03:47:08 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59370112063; Sat, 29 Jan 2022 03:47:08 +0000 (GMT) Received: from toto.the-meissners.org (unknown [9.77.136.59]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTPS; Sat, 29 Jan 2022 03:47:08 +0000 (GMT) Date: Fri, 28 Jan 2022 22:47:06 -0500 To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , David Edelsohn , Bill Schmidt , Peter Bergner , Will Schmidt Subject: [PATCH], PR 104253, Fix __ibm128 conversions on IEEE 128-bit system Message-ID: 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 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ntIf9f5TP0u1zcbwFPUVUGeCrqbRul-0 X-Proofpoint-ORIG-GUID: e8abuJtOL_7rer0vwgPb3_3khH_UymLp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-29_01,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 suspectscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201290017 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, KAM_SHORT, 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: Michael Meissner via Gcc-patches From: Michael Meissner Reply-To: Michael Meissner Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Use correct names for __ibm128 if long double is IEEE 128-bit. If you are on a PowerPC system where the default long double is IEEE 128-bit, GCC will use the wrong names for some of the conversion functions for the __ibm128 type. What is happening is when the defult long double is IEEE 128-bit, the various convert, truncation, and extend functions did not specify a default name for the conversion. The machine indepentent portions of the compiler would construct a call with an 'if' name (IFmode being the mode for IBM 128-bit floating point). This patch specifies to use the tradiational 'tf' name for these conversion functions. I have tested this on the following systems with no regressions. Can I check this into the trunk? This will need to be back ported to the GCC 11 branch also. * Power10, little endian, with IBM 128-bit long double default * Power10, little endian, with IEEE 128-bit long double default * Power9, little endian, with IBM 128-bit long double default * Power8, big endian, both 64/32-bit targets. Note, there is another bug that the original test case uncovered that we need a tweak for built-in handling for the __builtin_pack_ibm128 and __builtin_unpack_ibm128 built-in functions. This patch fixes the more general problem that the wrong conversion functions between DImode and IFmode were called. 2022-01-28 Michael Meissner gcc/ PR target/104253 * config/rs6000/rs6000.cc (init_float128_ibm): Use the TF names for builtin conversions between __ibm128 and DImode when long double uses the IEEE 128-bit format. gcc/testsuite/ PR target/104253 * gcc.target/powerpc/pr104253.c: New test. --- gcc/config/rs6000/rs6000.cc | 6 + gcc/testsuite/gcc.target/powerpc/pr104253.c | 154 ++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr104253.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index f5c089a2a26..3b4c496df56 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -11113,6 +11113,12 @@ init_float128_ibm (machine_mode mode) set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd"); set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd"); + set_conv_libfunc (sfix_optab, DImode, mode, "__fixtfdi"); + set_conv_libfunc (ufix_optab, DImode, mode, "__fixunstfdi"); + + set_conv_libfunc (sfloat_optab, mode, DImode, "__floatditf"); + set_conv_libfunc (ufloat_optab, mode, DImode, "__floatunditf"); + if (TARGET_POWERPC64) { set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti"); diff --git a/gcc/testsuite/gcc.target/powerpc/pr104253.c b/gcc/testsuite/gcc.target/powerpc/pr104253.c new file mode 100644 index 00000000000..a1e73fe012c --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr104253.c @@ -0,0 +1,154 @@ +/* + * Require float128 support because __ibm128 currently is not enabled unless we + * also have __float128 support. + */ + +/* { dg-do run } */ +/* { require-effective-target ppc_float128_sw } */ +/* { dg-options "-O2 -mvsx -mfloat128" } */ + +/* + * PR target/104253 + * + * Verify that the various conversions to and from __ibm128 work. When the + * default for long double is changed to IEEE 128-bit, originally GCC would + * call the functions using an 'if' name instead of 'tf. + */ + +#include + +extern float ibm128_to_sf (__ibm128) __attribute__((noinline)); +extern double ibm128_to_df (__ibm128) __attribute__((noinline)); +extern int ibm128_to_si (__ibm128) __attribute__((noinline)); +extern long long ibm128_to_di (__ibm128) __attribute__((noinline)); +extern unsigned int ibm128_to_usi (__ibm128) __attribute__((noinline)); +extern unsigned long long ibm128_to_udi (__ibm128) __attribute__((noinline)); + +extern __ibm128 sf_to_ibm128 (float) __attribute__((noinline)); +extern __ibm128 df_to_ibm128 (double) __attribute__((noinline)); +extern __ibm128 si_to_ibm128 (int) __attribute__((noinline)); +extern __ibm128 di_to_ibm128 (long long) __attribute__((noinline)); +extern __ibm128 usi_to_ibm128 (unsigned int) __attribute__((noinline)); +extern __ibm128 udi_to_ibm128 (unsigned long long) __attribute__((noinline)); + +float +ibm128_to_sf (__ibm128 x) +{ + return x; +} + +double +ibm128_to_df (__ibm128 x) +{ + return x; +} + +int +ibm128_to_si (__ibm128 x) +{ + return x; +} + +long long +ibm128_to_di (__ibm128 x) +{ + return x; +} + +unsigned int +ibm128_to_usi (__ibm128 x) +{ + return x; +} + +unsigned long long +ibm128_to_udi (__ibm128 x) +{ + return x; +} + +__ibm128 +sf_to_ibm128 (float x) +{ + return x; +} + +__ibm128 +df_to_ibm128 (double x) +{ + return x; +} + +__ibm128 +si_to_ibm128 (int x) +{ + return x; +} + +__ibm128 +di_to_ibm128 (long long x) +{ + return x; +} + +__ibm128 +usi_to_ibm128 (unsigned int x) +{ + return x; +} + +__ibm128 +udi_to_ibm128 (unsigned long long x) +{ + return x; +} + +volatile float seven_sf = 7.0f; +volatile double seven_df = 7.0; +volatile int seven_si = 7; +volatile long long seven_di = 7LL; +volatile unsigned int seven_usi = 7U; +volatile unsigned long long seven_udi = 7ULL; +volatile __ibm128 seven_ibm128 = 7.0; + +int +main (void) +{ + if (seven_ibm128 != sf_to_ibm128 (seven_sf)) + abort (); + + if (seven_ibm128 != df_to_ibm128 (seven_df)) + abort (); + + if (seven_ibm128 != si_to_ibm128 (seven_si)) + abort (); + + if (seven_ibm128 != di_to_ibm128 (seven_di)) + abort (); + + if (seven_ibm128 != usi_to_ibm128 (seven_usi)) + abort (); + + if (seven_ibm128 != udi_to_ibm128 (seven_udi)) + abort (); + + if (seven_sf != ibm128_to_sf (seven_ibm128)) + abort (); + + if (seven_df != ibm128_to_df (seven_ibm128)) + abort (); + + if (seven_si != ibm128_to_si (seven_ibm128)) + abort (); + + if (seven_di != ibm128_to_di (seven_ibm128)) + abort (); + + if (seven_usi != ibm128_to_usi (seven_ibm128)) + abort (); + + if (seven_udi != ibm128_to_udi (seven_ibm128)) + abort (); + + return 0; +}