Commit 30043df9 by Michael Meissner Committed by Michael Meissner

pack02.c: Use __ibm128 instead of long double if the long double format is IEEE 128-bit...

2018-06-21  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/pack02.c: Use __ibm128 instead of long double
	if the long double format is IEEE 128-bit for tests that are
	explicitly testing IBM extended double support.  Use the
	appropriate pack and unpack built-in functions.  Change calls from
	__builtin_isinfl to __builtin_isinf since the later supports all
	floating point types.
	* 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.

From-SVN: r261872
parent 27fbc519
2018-06-21 Michael Meissner <meissner@linux.ibm.com>
* gcc.target/powerpc/pack02.c: Use __ibm128 instead of long double
if the long double format is IEEE 128-bit for tests that are
explicitly testing IBM extended double support. Use the
appropriate pack and unpack built-in functions. Change calls from
__builtin_isinfl to __builtin_isinf since the later supports all
floating point types.
* 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.
2018-06-21 Paul Thomas <pault@gcc.gnu.org> 2018-06-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/49630 PR fortran/49630
......
...@@ -13,36 +13,54 @@ ...@@ -13,36 +13,54 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#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
int int
main (void) main (void)
{ {
double high = pow (2.0, 60); double high = pow (2.0, 60);
double low = 2.0; double low = 2.0;
long double a = ((long double)high) + ((long double)low); LDOUBLE a = ((LDOUBLE)high) + ((LDOUBLE)low);
double x0 = __builtin_unpack_longdouble (a, 0); double x0 = UNPACK (a, 0);
double x1 = __builtin_unpack_longdouble (a, 1); double x1 = UNPACK (a, 1);
long double b = __builtin_pack_longdouble (x0, x1); LDOUBLE b = PACK (x0, x1);
#ifdef DEBUG #ifdef DEBUG
{ {
size_t i; size_t i;
union { union {
long double ld; LDOUBLE ld;
double d; double d;
unsigned char uc[sizeof (long double)]; unsigned char uc[sizeof (LDOUBLE)];
char c[sizeof (long double)]; char c[sizeof (LDOUBLE)];
} u; } u;
printf ("a = 0x"); printf ("a = 0x");
u.ld = a; u.ld = a;
for (i = 0; i < sizeof (long double); i++) for (i = 0; i < sizeof (LDOUBLE); i++)
printf ("%.2x", u.uc[i]); printf ("%.2x", u.uc[i]);
printf (", %Lg\n", a); printf (", %Lg\n", a);
printf ("b = 0x"); printf ("b = 0x");
u.ld = b; u.ld = b;
for (i = 0; i < sizeof (long double); i++) for (i = 0; i < sizeof (LDOUBLE); i++)
printf ("%.2x", u.uc[i]); printf ("%.2x", u.uc[i]);
printf (", %Lg\n", b); printf (", %Lg\n", b);
...@@ -52,28 +70,28 @@ main (void) ...@@ -52,28 +70,28 @@ main (void)
for (i = 0; i < sizeof (double); i++) for (i = 0; i < sizeof (double); i++)
printf ("%.2x", u.uc[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"); printf ("lo = 0x");
u.d = low; u.d = low;
for (i = 0; i < sizeof (double); i++) for (i = 0; i < sizeof (double); i++)
printf ("%.2x", u.uc[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"); printf ("x0 = 0x");
u.d = x0; u.d = x0;
for (i = 0; i < sizeof (double); i++) for (i = 0; i < sizeof (double); i++)
printf ("%.2x", u.uc[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"); printf ("x1 = 0x");
u.d = x1; u.d = x1;
for (i = 0; i < sizeof (double); i++) for (i = 0; i < sizeof (double); i++)
printf ("%.2x", u.uc[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 #endif
......
...@@ -12,10 +12,24 @@ ...@@ -12,10 +12,24 @@
/* Insure caller save on long double does not use VSX instructions. */ /* Insure caller save on long double does not use VSX instructions. */
extern long double modify (long double); #if defined(__LONG_DOUBLE_IEEE128__)
/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
long double. 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 LDOUBLE __ibm128
#elif defined(__LONG_DOUBLE_IBM128__)
#define LDOUBLE long double
#else
#error "long double must be either IBM 128-bit or IEEE 128-bit"
#endif
extern LDOUBLE modify (LDOUBLE);
void void
sum (long double *ptr, long double value, unsigned long n) sum (LDOUBLE *ptr, LDOUBLE value, unsigned long n)
{ {
unsigned long i; unsigned long i;
......
...@@ -4,9 +4,23 @@ ...@@ -4,9 +4,23 @@
/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
/* { dg-options "-mcpu=power8 -O3" } */ /* { dg-options "-mcpu=power8 -O3" } */
union u_ld { long double ld; double d[2]; }; #if defined(__LONG_DOUBLE_IEEE128__)
/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
long double. 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 LDOUBLE __ibm128
long double #elif defined(__LONG_DOUBLE_IBM128__)
#define LDOUBLE long double
#else
#error "long double must be either IBM 128-bit or IEEE 128-bit"
#endif
union u_ld { LDOUBLE ld; double d[2]; };
LDOUBLE
pack (double a, double aa) pack (double a, double aa)
{ {
union u_ld u; union u_ld u;
...@@ -16,7 +30,7 @@ pack (double a, double aa) ...@@ -16,7 +30,7 @@ pack (double a, double aa)
} }
double double
unpack_0 (long double x) unpack_0 (LDOUBLE x)
{ {
union u_ld u; union u_ld u;
u.ld = x; u.ld = x;
...@@ -24,7 +38,7 @@ unpack_0 (long double x) ...@@ -24,7 +38,7 @@ unpack_0 (long double x)
} }
double double
unpack_1 (long double x) unpack_1 (LDOUBLE x)
{ {
union u_ld u; union u_ld u;
u.ld = x; u.ld = x;
......
...@@ -6,37 +6,51 @@ ...@@ -6,37 +6,51 @@
/* PR 67808: LRA ICEs on simple double to long double conversion test case */ /* PR 67808: LRA ICEs on simple double to long double conversion test case */
#if defined(__LONG_DOUBLE_IEEE128__)
/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
long double. 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 LDOUBLE __ibm128
#elif defined(__LONG_DOUBLE_IBM128__)
#define LDOUBLE long double
#else
#error "long double must be either IBM 128-bit or IEEE 128-bit"
#endif
void void
dfoo (long double *ldb1, double *db1) dfoo (LDOUBLE *ldb1, double *db1)
{ {
*ldb1 = *db1; *ldb1 = *db1;
} }
long double LDOUBLE
dfoo2 (double *db1) dfoo2 (double *db1)
{ {
return *db1; return *db1;
} }
long double LDOUBLE
dfoo3 (double x) dfoo3 (double x)
{ {
return x; return x;
} }
void void
ffoo (long double *ldb1, float *db1) ffoo (LDOUBLE *ldb1, float *db1)
{ {
*ldb1 = *db1; *ldb1 = *db1;
} }
long double LDOUBLE
ffoo2 (float *db1) ffoo2 (float *db1)
{ {
return *db1; return *db1;
} }
long double LDOUBLE
ffoo3 (float x) ffoo3 (float x)
{ {
return x; return x;
......
...@@ -3,10 +3,24 @@ ...@@ -3,10 +3,24 @@
#include <float.h> #include <float.h>
#if defined(__LONG_DOUBLE_IEEE128__)
/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
long double. 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 LDOUBLE __ibm128
#elif defined(__LONG_DOUBLE_IBM128__)
#define LDOUBLE long double
#else
#error "long double must be either IBM 128-bit or IEEE 128-bit"
#endif
union gl_long_double_union union gl_long_double_union
{ {
struct { double hi; double lo; } dd; struct { double hi; double lo; } dd;
long double ld; LDOUBLE ld;
}; };
/* This is gnulib's LDBL_MAX which, being 107 bits in precision, is /* This is gnulib's LDBL_MAX which, being 107 bits in precision, is
...@@ -22,13 +36,13 @@ volatile double dnan = 0.0/0.0; ...@@ -22,13 +36,13 @@ volatile double dnan = 0.0/0.0;
int int
main (void) main (void)
{ {
long double ld; LDOUBLE ld;
ld = gl_LDBL_MAX.ld; ld = gl_LDBL_MAX.ld;
if (__builtin_isinfl (ld)) if (__builtin_isinf (ld))
__builtin_abort (); __builtin_abort ();
ld = -gl_LDBL_MAX.ld; ld = -gl_LDBL_MAX.ld;
if (__builtin_isinfl (ld)) if (__builtin_isinf (ld))
__builtin_abort (); __builtin_abort ();
ld = gl_LDBL_MAX.ld; ld = gl_LDBL_MAX.ld;
......
...@@ -4,7 +4,19 @@ ...@@ -4,7 +4,19 @@
/* { dg-require-effective-target longdouble128 } */ /* { dg-require-effective-target longdouble128 } */
/* { dg-options "-O2 -fno-align-functions -fno-asynchronous-unwind-tables -mtraceback=no -save-temps" } */ /* { 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__)
/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
long double. 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 TFmode __ibm128
#elif defined(__LONG_DOUBLE_IBM128__)
#define TFmode long double
#else
#error "long double must be either IBM 128-bit or IEEE 128-bit"
#endif
void w1 (void *x, TFmode y) { *(TFmode *) (x + 32767) = y; } void w1 (void *x, TFmode y) { *(TFmode *) (x + 32767) = y; }
void w2 (void *x, TFmode y) { *(TFmode *) (x + 32766) = y; } void w2 (void *x, TFmode y) { *(TFmode *) (x + 32766) = y; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment