re PR target/85657 (Make __ibm128 a separate type, even if long double uses the IBM...
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr85657-1.c
blob3337d06332d63f3afe46efefaab63151fa578bec
1 /* { dg-do compile { target { powerpc*-*-linux* } } } */
2 /* { dg-require-effective-target ppc_float128_sw } */
3 /* { dg-options "-mvsx -mfloat128 -O2 -mabi=ibmlongdouble -Wno-psabi" } */
5 // PR 85657 -- make sure conversions work between each of the 128-bit floating
6 // point types.
8 __attribute__ ((__noinline__))
9 __float128
10 ibm128_to_float128 (__ibm128 a)
12 return (__float128)a;
15 __attribute__ ((__noinline__))
16 __float128
17 ldouble_to_float128 (long double a)
19 return (__float128)a;
22 __attribute__ ((__noinline__))
23 __ibm128
24 float128_to_ibm128 (__float128 a)
26 return (__ibm128)a;
29 __attribute__ ((__noinline__))
30 __ibm128
31 ldouble_to_ibm128 (long double a)
33 return (__ibm128)a;
36 __attribute__ ((__noinline__))
37 long double
38 ibm128_to_ldouble (__ibm128 a)
40 return (long double)a;
43 __attribute__ ((__noinline__))
44 long double
45 float128_to_ldouble (__float128 a)
47 return (long double)a;
50 #ifdef TEST
51 #include <stdio.h>
53 volatile __float128 f128 = 1.2Q;
54 volatile __ibm128 i128 = (__ibm128)3.4L;
55 volatile long double ld = 5.6L;
57 int
58 main (void)
60 printf ("f128 (1.2) = %g (ld), %g (ibm128)\n",
61 (double) float128_to_ldouble (f128),
62 (double) float128_to_ibm128 (f128));
64 printf ("i128 (3.4) = %g (ld), %g (float128)\n",
65 (double) ibm128_to_ldouble (i128),
66 (double) ibm128_to_float128 (i128));
68 printf ("long double (5.6) = %g (ibm128), %g (float128)\n",
69 (double) ldouble_to_ibm128 (ld),
70 (double) ldouble_to_float128 (ld));
72 return 0;
74 #endif