From patchwork Wed Jun 13 21:16:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 929089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479674-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SysX9X04"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415fhX2Xvwz9s2g for ; Thu, 14 Jun 2018 07:16:58 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:references:mime-version:content-type :in-reply-to:message-id; q=dns; s=default; b=uN1+C8dm/ZItais++m6 KQ9nvL8uCkioCmz6TRw8chL4I2crffcSdLClgqo+lb0gTdhpUbV3i4QKmFP4vUUe qOr4x5PRMiFRQeXEBircTHJ7mL6RZWgXkJ8MQy4JgaQhsxFlQkE+dGlih/4zTl3y iX71+kzSaw+ozyNcOgHeVyBM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:references:mime-version:content-type :in-reply-to:message-id; s=default; bh=kQuE0uPhNlk+yp6v7CM2Z7PLn c8=; b=SysX9X04qQkvSPEEw7H822YXOSKD9+71JF/N5YTV85bL/gfp4pP8MsE4J dNWEFWb12rpoh+nHyHz1zB3mhdTAUwHIQkm9WUypHcLZ3I9s6ZtWgqicX2096qw+ 3B6zyxejrzwuxCfcm5y151+GmILPixybvJSXqH0ZXdAcR5QdqU= Received: (qmail 65040 invoked by alias); 13 Jun 2018 21:16:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 64976 invoked by uid 89); 13 Jun 2018 21:16:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 21:16:45 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5DLDrJW120080 for ; Wed, 13 Jun 2018 17:16:43 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jk9rn2yr8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 13 Jun 2018 17:16:43 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Jun 2018 17:16:42 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 13 Jun 2018 17:16:40 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5DLGdXt64684050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Jun 2018 21:16:39 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68886B2065; Wed, 13 Jun 2018 17:16:36 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 23185B2066; Wed, 13 Jun 2018 17:16:36 -0400 (EDT) Received: from ibm-toto.the-meissners.org (unknown [9.32.77.218]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTPS; Wed, 13 Jun 2018 17:16:36 -0400 (EDT) Date: Wed, 13 Jun 2018 17:16:37 -0400 From: Michael Meissner To: Michael Meissner , GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt Subject: [PATCH], PowerPC long double transistion, patch #2 Mail-Followup-To: Michael Meissner , GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt References: <20180613211015.GA3737@ibm-toto.the-meissners.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180613211015.GA3737@ibm-toto.the-meissners.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18061321-0072-0000-0000-0000036E4712 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009185; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01046527; UDB=6.00535982; IPR=6.00825502; MB=3.00021630; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-13 21:16:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061321-0073-0000-0000-0000485AF30E Message-Id: <20180613211637.GA5861@ibm-toto.the-meissners.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-13_09:, , signatures=0 In addition to the previous patch to aid in transitioning the PowerPC long double format to IEEE 128-bit, I have some additional patches that are needed. The previous patch is: https://gcc.gnu.org/ml/gcc-patches/2018-06/msg00634.html This fixes some of the PowerPC tests that had implicit assumptions about the long double format. The fixes involved: 1) Using long double __complex instead of using a KC attribute; 2) Explicitly adding -mabi=ibmlongdouble; (or) 3) Using __ibm128 instead of long double if long double is IEEE 128-bit. I have done separate bootstraps on a little endian power8 system with the long double type set to IBM extended and IEEE 128-bit extended. There were no regressions in using this patch, and it fixes several of the errors when you use a compiler with long double defaulting to IEEE 128-bit floating point. Can I check it in, and eventually back port it to GCC 8.2 with the other long double transition patches. 2018-06-13 Michael Meissner * gcc.target/powerpc/divkc3-1.c: If long double is IEEE 128-bit, use __complex long double instead of KC attribute. * gcc.target/powerpc/mulkc3-1.c: Likewise. * gcc.target/powerpc/float128-3.c: Add -mabi=ibmlongdouble to tests that require long double to be IBM extended double. * gcc.target/powerpc/float128-5.c: Likewise. * gcc.target/powerpc/float128-mix.c: Likewise. * gcc.target/powerpc/pack02.c: On systems where long double is IEEE 128-bit, use __ibm128 instead of long double. Use the ibm128 pack/unpack functions instead of the long double pack/unpack functions. * gcc.target/powerpc/pr57150.c: Likewise. * gcc.target/powerpc/pr60203.c: Likewise. * gcc.target/powerpc/pr67808.c: Likewise. * gcc.target/powerpc/pr70117.c: Likewise. * gcc.target/powerpc/tfmode_off.c: Likewise. Index: gcc/testsuite/gcc.target/powerpc/divkc3-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/divkc3-1.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/divkc3-1.c (working copy) @@ -3,7 +3,11 @@ void abort (); -typedef __complex float __cfloat128 __attribute__((mode(KC))); +#ifdef __LONG_DOUBLE_IEEE128__ +typedef __complex long double __cfloat128; +#else +typedef __complex float __cfloat128 __attribute__((mode(__KC__))); +#endif __cfloat128 divide (__cfloat128 x, __cfloat128 y) { Index: gcc/testsuite/gcc.target/powerpc/float128-3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/float128-3.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/float128-3.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-linux* } } } */ /* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-options "-O2 -mvsx -mno-float128" } */ +/* { dg-options "-O2 -mvsx -mno-float128 -mabi=ibmlongdouble -Wno-psabi" } */ /* Test that we can use #pragma GCC target to enable -mfloat128. */ Index: gcc/testsuite/gcc.target/powerpc/float128-5.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/float128-5.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/float128-5.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-options "-O2 -mpower9-vector -mno-float128" } */ +/* { dg-options "-O2 -mpower9-vector -mno-float128 -mabi=ibmlongdouble -Wno-psabi" } */ /* Test that we can use #pragma GCC target to enable -mfloat128 and generate code on ISA 3.0 for the float128 built-in functions. Lp64 is required Index: gcc/testsuite/gcc.target/powerpc/float128-mix.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/float128-mix.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/float128-mix.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-linux* } } } */ /* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-options "-O2 -mvsx" } */ +/* { dg-options "-O2 -mvsx -mabi=ibmlongdouble -Wno-psabi" } */ /* Test to make sure that __float128 and long double cannot be combined together. */ Index: gcc/testsuite/gcc.target/powerpc/mulkc3-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/mulkc3-1.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/mulkc3-1.c (working copy) @@ -3,7 +3,11 @@ void abort (); -typedef __complex float __cfloat128 __attribute__((mode(KC))); +#ifdef __LONG_DOUBLE_IEEE128__ +typedef __complex long double __cfloat128; +#else +typedef __complex float __cfloat128 __attribute__((mode(__KC__))); +#endif __cfloat128 multiply (__cfloat128 x, __cfloat128 y) { Index: gcc/testsuite/gcc.target/powerpc/pack02.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pack02.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/pack02.c (working copy) @@ -9,6 +9,20 @@ #include #include +#if defined(__LONG_DOUBLE_IEEE128__) +#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 __ibm128 + +#else +#error "long double must be either IBM 128-bit or IEEE 128-bit" +#endif + #ifdef DEBUG #include #endif @@ -18,31 +32,31 @@ main (void) { double high = pow (2.0, 60); double low = 2.0; - long double a = ((long double)high) + ((long double)low); - double x0 = __builtin_unpack_longdouble (a, 0); - double x1 = __builtin_unpack_longdouble (a, 1); - long double b = __builtin_pack_longdouble (x0, x1); + LDOUBLE a = ((LDOUBLE)high) + ((LDOUBLE)low); + double x0 = UNPACK (a, 0); + double x1 = UNPACK (a, 1); + LDOUBLE b = PACK (x0, x1); #ifdef DEBUG { size_t i; union { - long double ld; + LDOUBLE ld; double d; - unsigned char uc[sizeof (long double)]; - char c[sizeof (long double)]; + unsigned char uc[sizeof (LDOUBLE)]; + char c[sizeof (LDOUBLE)]; } u; printf ("a = 0x"); u.ld = a; - for (i = 0; i < sizeof (long double); i++) + for (i = 0; i < sizeof (LDOUBLE); i++) printf ("%.2x", u.uc[i]); printf (", %Lg\n", a); printf ("b = 0x"); u.ld = b; - for (i = 0; i < sizeof (long double); i++) + for (i = 0; i < sizeof (LDOUBLE); i++) printf ("%.2x", u.uc[i]); printf (", %Lg\n", b); @@ -52,28 +66,28 @@ main (void) for (i = 0; i < sizeof (double); i++) printf ("%.2x", u.uc[i]); - printf (",%*s %g\n", (int)(2 * (sizeof (long double) - sizeof (double))), "", high); + printf (",%*s %g\n", (int)(2 * (sizeof (LDOUBLE) - sizeof (double))), "", high); printf ("lo = 0x"); u.d = low; for (i = 0; i < sizeof (double); i++) printf ("%.2x", u.uc[i]); - printf (",%*s %g\n", (int)(2 * (sizeof (long double) - sizeof (double))), "", low); + printf (",%*s %g\n", (int)(2 * (sizeof (LDOUBLE) - sizeof (double))), "", low); printf ("x0 = 0x"); u.d = x0; for (i = 0; i < sizeof (double); i++) printf ("%.2x", u.uc[i]); - printf (",%*s %g\n", (int)(2 * (sizeof (long double) - sizeof (double))), "", x0); + printf (",%*s %g\n", (int)(2 * (sizeof (LDOUBLE) - sizeof (double))), "", x0); printf ("x1 = 0x"); u.d = x1; for (i = 0; i < sizeof (double); i++) printf ("%.2x", u.uc[i]); - printf (",%*s %g\n", (int)(2 * (sizeof (long double) - sizeof (double))), "", x1); + printf (",%*s %g\n", (int)(2 * (sizeof (LDOUBLE) - sizeof (double))), "", x1); } #endif Index: gcc/testsuite/gcc.target/powerpc/pr57150.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr57150.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/pr57150.c (working copy) @@ -10,12 +10,22 @@ /* { dg-final { scan-assembler-not "stxvw4x" } } */ /* { dg-final { scan-assembler-not "stvx" } } */ -/* Insure caller save on long double does not use VSX instructions. */ +/* Insure caller save on long double/ibm128 does not use VSX instructions. */ -extern long double modify (long double); +#if defined(__LONG_DOUBLE_IEEE128__) +#define LDOUBLE __ibm128 + +#elif defined(__LONG_DOUBLE_IBM128__) +#define LDOUBLE long double + +#else +#error "long double must be IBM 128-bit or IEEE 128-bit" +#endif + +extern LDOUBLE modify (LDOUBLE); void -sum (long double *ptr, long double value, unsigned long n) +sum (LDOUBLE *ptr, LDOUBLE value, unsigned long n) { unsigned long i; Index: gcc/testsuite/gcc.target/powerpc/pr60203.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr60203.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/pr60203.c (working copy) @@ -4,9 +4,19 @@ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ /* { dg-options "-mcpu=power8 -O3" } */ -union u_ld { long double ld; double d[2]; }; +#if defined(__LONG_DOUBLE_IEEE128__) +#define LDOUBLE __ibm128 -long double +#elif defined(__LONG_DOUBLE_IBM128__) +#define LDOUBLE long double + +#else +#error "long double must be IBM 128-bit or IEEE 128-bit" +#endif + +union u_ld { LDOUBLE ld; double d[2]; }; + +LDOUBLE pack (double a, double aa) { union u_ld u; @@ -16,7 +26,7 @@ pack (double a, double aa) } double -unpack_0 (long double x) +unpack_0 (LDOUBLE x) { union u_ld u; u.ld = x; @@ -24,7 +34,7 @@ unpack_0 (long double x) } double -unpack_1 (long double x) +unpack_1 (LDOUBLE x) { union u_ld u; u.ld = x; Index: gcc/testsuite/gcc.target/powerpc/pr67808.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr67808.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/pr67808.c (working copy) @@ -6,37 +6,47 @@ /* PR 67808: LRA ICEs on simple double to long double conversion test case */ +#if defined(__LONG_DOUBLE_IEEE128__) +#define LDOUBLE __ibm128 + +#elif defined(__LONG_DOUBLE_IBM128__) +#define LDOUBLE long double + +#else +#error "long double must be IBM 128-bit or IEEE 128-bit" +#endif + void -dfoo (long double *ldb1, double *db1) +dfoo (LDOUBLE *ldb1, double *db1) { *ldb1 = *db1; } -long double +LDOUBLE dfoo2 (double *db1) { return *db1; } -long double +LDOUBLE dfoo3 (double x) { return x; } void -ffoo (long double *ldb1, float *db1) +ffoo (LDOUBLE *ldb1, float *db1) { *ldb1 = *db1; } -long double +LDOUBLE ffoo2 (float *db1) { return *db1; } -long double +LDOUBLE ffoo3 (float x) { return x; Index: gcc/testsuite/gcc.target/powerpc/pr70117.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr70117.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/pr70117.c (working copy) @@ -3,10 +3,20 @@ #include +#if defined(__LONG_DOUBLE_IEEE128__) +#define LDOUBLE __ibm128 + +#elif defined(__LONG_DOUBLE_IBM128__) +#define LDOUBLE long double + +#else +#error "long double must be IBM 128-bit or IEEE 128-bit" +#endif + union gl_long_double_union { struct { double hi; double lo; } dd; - long double ld; + LDOUBLE ld; }; /* This is gnulib's LDBL_MAX which, being 107 bits in precision, is @@ -22,13 +32,13 @@ volatile double dnan = 0.0/0.0; int main (void) { - long double ld; + LDOUBLE ld; ld = gl_LDBL_MAX.ld; if (__builtin_isinfl (ld)) __builtin_abort (); ld = -gl_LDBL_MAX.ld; - if (__builtin_isinfl (ld)) + if (__builtin_isinf (ld)) __builtin_abort (); ld = gl_LDBL_MAX.ld; Index: gcc/testsuite/gcc.target/powerpc/tfmode_off.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/tfmode_off.c (revision 261511) +++ gcc/testsuite/gcc.target/powerpc/tfmode_off.c (working copy) @@ -4,7 +4,15 @@ /* { dg-require-effective-target longdouble128 } */ /* { dg-options "-O2 -fno-align-functions -fno-asynchronous-unwind-tables -mtraceback=no -save-temps" } */ -typedef float TFmode __attribute__ ((mode (TF))); +#if defined(__LONG_DOUBLE_IEEE128__) +#define TFmode __ibm128 + +#elif defined(__LONG_DOUBLE_IBM128__) +#define TFmode long double + +#else +#error "long double must be IBM 128-bit or IEEE 128-bit" +#endif void w1 (void *x, TFmode y) { *(TFmode *) (x + 32767) = y; } void w2 (void *x, TFmode y) { *(TFmode *) (x + 32766) = y; }