This patch fixes the tests that use IEEE 128-bit float complex to use long
double _Complex on systems where the default is IEEE 128-bit.  Due to needing
to use the same internal type for long double and __float128 (to get the
mangling correct and make templates work), you can't really use KF or KC
attributes to get the float128 type when the long double type is IEEE 128-bit.

The compiler does have defines for __KC__ and __KF__ to convert them to __TC__
and __TF__ to allow older GLIBC include files to work.  But these tests just
used KC and/or KF.

I tested these on a little endian power8 system with toolchains that use both
128-bit long double types, and these test pass.  Can I check these patches into
the trunk and into the GCC 8.x branches?

[gcc/testsuite]
2018-06-20  Michael Meissner  <meiss...@linux.ibm.com>

        * gcc.target/powerpc/divkc3-1.c: If the long double default is
        IEEE use long double _Complex to declare the IEEE 128-bit complex
        type.
        * gcc.target/powerpc/float128-complex-1.c: Likewise.
        * gcc.target/powerpc/float128-complex-2.c: Likewise.
        * gcc.target/powerpc/float128-type-1.c: Likewise.
        * gcc.target/powerpc/float128-type-2.c: Likewise.
        * gcc.target/powerpc/mulkc3-1.c: Likewise.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797
Index: gcc/testsuite/gcc.target/powerpc/divkc3-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/divkc3-1.c (revision 261755)
+++ gcc/testsuite/gcc.target/powerpc/divkc3-1.c (working copy)
@@ -3,7 +3,14 @@
 
 void abort ();
 
-typedef __complex float __cfloat128 __attribute__((mode(KC)));
+#ifndef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef _Complex float __attribute__((mode(__KC__)))   __cfloat128;
+#else
+typedef _Complex long double                           __cfloat128;
+#endif
 
 __cfloat128 divide (__cfloat128 x, __cfloat128 y)
 {
Index: gcc/testsuite/gcc.target/powerpc/float128-complex-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/float128-complex-1.c       (revision 
261755)
+++ gcc/testsuite/gcc.target/powerpc/float128-complex-1.c       (working copy)
@@ -33,10 +33,13 @@ extern double_complex cdouble2 (void);
 #endif
 
 #ifndef NO_FLOAT128
-#ifdef __VSX__
-typedef _Complex float __attribute__((mode(KC)))       float128_complex;
+#ifndef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef _Complex float __attribute__((__mode__(__KC__))) float128_complex;
 #else
-typedef _Complex float __attribute__((mode(TC)))       float128_complex;
+typedef _Complex long double                            float128_complex;
 #endif
 
 extern float128_complex cfloat128_1 (void);
Index: gcc/testsuite/gcc.target/powerpc/float128-complex-2.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/float128-complex-2.c       (revision 
261755)
+++ gcc/testsuite/gcc.target/powerpc/float128-complex-2.c       (working copy)
@@ -34,10 +34,13 @@ extern double_complex cdouble2 (void);
 #endif
 
 #ifndef NO_FLOAT128
-#ifdef __VSX__
-typedef _Complex float __attribute__((mode(KC)))       float128_complex;
+#ifndef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef _Complex float __attribute__((__mode__(__KC__))) float128_complex;
 #else
-typedef _Complex float __attribute__((mode(TC)))       float128_complex;
+typedef _Complex long double                            float128_complex;
 #endif
 
 extern float128_complex cfloat128_1 (void);
Index: gcc/testsuite/gcc.target/powerpc/float128-type-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/float128-type-1.c  (revision 261755)
+++ gcc/testsuite/gcc.target/powerpc/float128-type-1.c  (working copy)
@@ -8,9 +8,12 @@
    __float128 is not enabled .  Test that power8 generates a call to the
    __addkf3 emulation function.  */
 
-#ifdef __LONG_DOUBLE_IEEE128
-typedef double          __attribute__((__mode__(__TF__))) f128_t;
-typedef _Complex double __attribute__((__mode__(__TC__))) f128c_t;
+#ifdef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef long double            f128_t;
+typedef long double _Complex   f128c_t;
 
 #else
 typedef double          __attribute__((__mode__(__KF__))) f128_t;
Index: gcc/testsuite/gcc.target/powerpc/float128-type-2.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/float128-type-2.c  (revision 261755)
+++ gcc/testsuite/gcc.target/powerpc/float128-type-2.c  (working copy)
@@ -8,9 +8,12 @@
    __float128 is not enabled .  Test that power9 generates the xsaddqp
    instruction.  */
 
-#ifdef __LONG_DOUBLE_IEEE128
-typedef double          __attribute__((__mode__(__TF__))) f128_t;
-typedef _Complex double __attribute__((__mode__(__TC__))) f128c_t;
+#ifdef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef long double            f128_t;
+typedef long double _Complex   f128c_t;
 
 #else
 typedef double          __attribute__((__mode__(__KF__))) f128_t;
Index: gcc/testsuite/gcc.target/powerpc/mulkc3-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/mulkc3-1.c (revision 261755)
+++ gcc/testsuite/gcc.target/powerpc/mulkc3-1.c (working copy)
@@ -3,7 +3,15 @@
 
 void abort ();
 
-typedef __complex float __cfloat128 __attribute__((mode(KC)));
+
+#ifndef __LONG_DOUBLE_IEEE128__
+/* If long double is IBM, we have to use __attribute__ to get to the long
+   double complex type.  If long double is IEEE, we can use the standard
+   _Complex type.  */
+typedef _Complex float __attribute__((mode(__KC__)))   __cfloat128;
+#else
+typedef _Complex long double                           __cfloat128;
+#endif
 
 __cfloat128 multiply (__cfloat128 x, __cfloat128 y)
 {

Reply via email to