[gcc(refs/users/meissner/heads/work169-bugs)] Do not build IEEE 128-bit support for little endian power5.

Michael Meissner meissner@gcc.gnu.org
Mon Jun 17 22:41:24 GMT 2024


https://gcc.gnu.org/g:d1a317cacda5fe14e90ef2beefd8d19923ec696a

commit d1a317cacda5fe14e90ef2beefd8d19923ec696a
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon Jun 17 18:41:05 2024 -0400

    Do not build IEEE 128-bit support for little endian power5.
    
    2024-06-17  Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            * config/rs6000/rs6000.cc (rs6000_option_override_internal): Do not
            allow IEEE 128-bit on little endian 32-bit systems.
    
    libgcc/
    
            * config.host (powerpc*-linux*): Do not build the IEEE 128-bit support
            libraries unless GCC is configured for at least power8 by default.
            * configure.ac (powerpc*-linux*): Likewise.
            * configure: Regenerate.
    
    libgfortran/
    
            * configure.ac (powerpc64le*-linux*): Check to see that the compiler
            uses VSX before enabling IEEE 128-bit support.
            * configure: Regenerate.
            * kinds-override.h: Do not enable IEEE 128-bit floating point support on
            little endian PowerPC that does not have VSX support.

Diff:
---
 gcc/config/rs6000/rs6000.cc  | 13 ++++++++++++-
 libgcc/config.host           | 14 ++++++++------
 libgcc/configure             |  9 ++++++++-
 libgcc/configure.ac          |  9 ++++++++-
 libgfortran/configure        |  7 +++++--
 libgfortran/configure.ac     |  3 +++
 libgfortran/kinds-override.h |  2 +-
 7 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index c5c4191127e4..ea36e651b446 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -4146,7 +4146,8 @@ rs6000_option_override_internal (bool global_init_p)
      the keyword as well as the type.  */
   TARGET_FLOAT128_TYPE = TARGET_FLOAT128_ENABLE_TYPE && TARGET_VSX;
 
-  /* IEEE 128-bit floating point requires VSX support.  */
+  /* IEEE 128-bit floating point requires VSX support.  Disable IEEE 128-bit on
+     legacy 32-bit LE systems.  */
   if (TARGET_FLOAT128_KEYWORD)
     {
       if (!TARGET_VSX)
@@ -4154,6 +4155,16 @@ rs6000_option_override_internal (bool global_init_p)
 	  if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) != 0)
 	    error ("%qs requires VSX support", "-mfloat128");
 
+	  TARGET_FLOAT128_TYPE = 0;
+	  rs6000_isa_flags &= ~(OPTION_MASK_FLOAT128_KEYWORD
+				| OPTION_MASK_FLOAT128_HW);
+	}
+      else if (!TARGET_POWERPC64 && !BYTES_BIG_ENDIAN)
+	{
+	  if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) != 0)
+	    error ("%qs requires 64-bit support on little endian systems",
+		   "-mfloat128");
+
 	  TARGET_FLOAT128_TYPE = 0;
 	  rs6000_isa_flags &= ~(OPTION_MASK_FLOAT128_KEYWORD
 				| OPTION_MASK_FLOAT128_HW);
diff --git a/libgcc/config.host b/libgcc/config.host
index 9fae51d4ce7d..9e3b21e98fdd 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1290,16 +1290,18 @@ powerpc*-*-linux*)
 		;;
 	esac
 
+	# If the compiler is not configured for IEEE 128-bit, do not include the
+	# power9 and power10 hardware support libraries
 	if test $libgcc_cv_powerpc_float128 = yes; then
 		tmake_file="${tmake_file} rs6000/t-float128"
-	fi
 
-	if test $libgcc_cv_powerpc_float128_hw = yes; then
-		tmake_file="${tmake_file} rs6000/t-float128-hw"
-	fi
+		if test $libgcc_cv_powerpc_float128_hw = yes; then
+			tmake_file="${tmake_file} rs6000/t-float128-hw"
 
-	if test $libgcc_cv_powerpc_3_1_float128_hw = yes; then
-		tmake_file="${tmake_file} rs6000/t-float128-p10-hw"
+			if test $libgcc_cv_powerpc_3_1_float128_hw = yes; then
+				tmake_file="${tmake_file} rs6000/t-float128-p10-hw"
+			fi
+		fi
 	fi
 
 	extra_parts="$extra_parts ecrti.o ecrtn.o ncrti.o ncrtn.o"
diff --git a/libgcc/configure b/libgcc/configure
index a69d314374a3..f61c9c9b3937 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -5184,9 +5184,16 @@ case ${host} in
 # check if we have VSX (ISA 2.06) support to build the software libraries, and
 # whether the assembler can handle xsaddqp for hardware support.  Also check if
 # a new glibc is being used so that __builtin_cpu_supports can be used.
+#
+# Originally we added -mabi=altivec -mvsx to the tests to see if we could
+# support IEEE 128-bit.  This would mean that even if the compiler was
+# configured for power5, it would build the IEEE 128-bit libraries by adding
+# -mvsx.  Instead if you want IEEE 128-bit support, you have to configure the
+# compiler to build ISA 2.06 (power8) by default.  We do add -mfloat128 to
+# cater to systems where IEEE 128-bit might not be enabled by default.
 powerpc*-*-linux*)
   saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128"
+  CFLAGS="$CFLAGS -mfloat128"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 2.06 to build __float128 libraries" >&5
 $as_echo_n "checking for PowerPC ISA 2.06 to build __float128 libraries... " >&6; }
 if ${libgcc_cv_powerpc_float128+:} false; then :
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index c2749fe09584..d9941c0b1a6a 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -407,9 +407,16 @@ case ${host} in
 # check if we have VSX (ISA 2.06) support to build the software libraries, and
 # whether the assembler can handle xsaddqp for hardware support.  Also check if
 # a new glibc is being used so that __builtin_cpu_supports can be used.
+#
+# Originally we added -mabi=altivec -mvsx to the tests to see if we could
+# support IEEE 128-bit.  This would mean that even if the compiler was
+# configured for power5, it would build the IEEE 128-bit libraries by adding
+# -mvsx.  Instead if you want IEEE 128-bit support, you have to configure the
+# compiler to build ISA 2.06 (power8) by default.  We do add -mfloat128 to
+# cater to systems where IEEE 128-bit might not be enabled by default.
 powerpc*-*-linux*)
   saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128"
+  CFLAGS="$CFLAGS -mfloat128"
   AC_CACHE_CHECK([for PowerPC ISA 2.06 to build __float128 libraries],
 		 [libgcc_cv_powerpc_float128],
 		 [AC_COMPILE_IFELSE(
diff --git a/libgfortran/configure b/libgfortran/configure
index 11a1bc5f0708..2708e5c7eca4 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -5981,6 +5981,9 @@ if test "x$GCC" = "xyes"; then
 #if __SIZEOF_LONG_DOUBLE__ != 16
 			   #error long double is double
 			   #endif
+			   #if !defined(__VSX__)
+			   #error VSX is not available
+			   #endif
 int
 main ()
 {
@@ -12847,7 +12850,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12850 "configure"
+#line 12853 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12953,7 +12956,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12956 "configure"
+#line 12959 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index cca1ea0ea970..cfaeb9717ab8 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -148,6 +148,9 @@ if test "x$GCC" = "xyes"; then
       AC_PREPROC_IFELSE(
         [AC_LANG_PROGRAM([[#if __SIZEOF_LONG_DOUBLE__ != 16
 			   #error long double is double
+			   #endif
+			   #if !defined(__VSX__)
+			   #error VSX is not available
 			   #endif]],
                          [[(void) 0;]])],
         [AM_FCFLAGS="$AM_FCFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
diff --git a/libgfortran/kinds-override.h b/libgfortran/kinds-override.h
index f6b4956c5caa..51f440e53232 100644
--- a/libgfortran/kinds-override.h
+++ b/libgfortran/kinds-override.h
@@ -30,7 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #endif
 
 /* Keep these conditions on one line so grep can filter it out.  */
-#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && __SIZEOF_LONG_DOUBLE__ == 16
+#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && __SIZEOF_LONG_DOUBLE__ == 16 && defined(__VSX__)
 typedef _Float128 GFC_REAL_17;
 typedef _Complex _Float128 GFC_COMPLEX_17;
 #define HAVE_GFC_REAL_17


More information about the Gcc-cvs mailing list