https://gcc.gnu.org/g:a92ecfb87c48c9a4c7a7e12d5ec1491198ea0e18
commit a92ecfb87c48c9a4c7a7e12d5ec1491198ea0e18 Author: Michael Meissner <meiss...@linux.ibm.com> Date: Fri Jul 12 20:58:20 2024 -0400 Use -mcpu=power7 if needed and not -mvsx to build float128 support. 2024-07-12 Michael Meissner <meiss...@linux.ibm.com> libgcc/ PR target/115800 PR target/113652 * config.host (powerpc*-*-linux*): Do not enable the float128 hardware and float128 power10 hardware support unless the basic float128 support is added. Add support for building the float128 support when the default compiler does not enable VSX. * config/rs6000/t-float128 (FP128_CFLAGS_SW): Do not use -mvsx, instead use FP128_CFLAGS_VSX to optionally add -mcpu=power7. * config/rs6000/t-float128-vsx: New file. * configure.ac (powerpc*-*-linux*): Determine if the default powerpc cpu includes VSX support. * configure: Regenerate. Diff: --- libgcc/config.host | 16 ++++++++++------ libgcc/config/rs6000/t-float128 | 2 +- libgcc/config/rs6000/t-float128-vsx | 3 +++ libgcc/configure | 29 ++++++++++++++++++++++++----- libgcc/configure.ac | 17 ++++++++++++----- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/libgcc/config.host b/libgcc/config.host index 9fae51d4ce7d..804d12e8fd6a 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1291,15 +1291,19 @@ powerpc*-*-linux*) esac if test $libgcc_cv_powerpc_float128 = yes; then + if test $libgcc_cv_powerpc_vsx = no; then + tmake_file="${tmake_file} rs6000/t-float128-vsx" + fi + 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/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 index b09b5664af0e..8037a6290a82 100644 --- a/libgcc/config/rs6000/t-float128 +++ b/libgcc/config/rs6000/t-float128 @@ -74,7 +74,7 @@ fp128_includes = $(srcdir)/soft-fp/double.h \ $(srcdir)/soft-fp/soft-fp.h # Build the emulator without ISA 3.0 hardware support. -FP128_CFLAGS_SW = -Wno-type-limits -mvsx -mfloat128 \ +FP128_CFLAGS_SW = -Wno-type-limits $(FLOAT128_CFLAGS_VSX) -mfloat128 \ -mno-float128-hardware -mno-gnu-attribute \ -I$(srcdir)/soft-fp \ -I$(srcdir)/config/rs6000 \ diff --git a/libgcc/config/rs6000/t-float128-vsx b/libgcc/config/rs6000/t-float128-vsx new file mode 100644 index 000000000000..c691546242d9 --- /dev/null +++ b/libgcc/config/rs6000/t-float128-vsx @@ -0,0 +1,3 @@ +# Add -mcpu=power7 option if the default compiler does not support VSX + +FLOAT128_CFLAGS_VSX = -mabi=altivec -mcpu=power7 diff --git a/libgcc/configure b/libgcc/configure index a69d314374a3..ad12baf965f4 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -5180,13 +5180,32 @@ esac esac case ${host} in -# At present, we cannot turn -mfloat128 on via #pragma GCC target, so just -# 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. +# Test if the default compiler enables VSX. If it does not, we need to build +# the float128 bit support using -mcpu=power7 to enable the VSX instruction set. +# +# Also check if a new glibc is being used so that __builtin_cpu_supports can be +# used. powerpc*-*-linux*) saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if VSX is enabled by default" >&5 +$as_echo_n "checking if VSX is enabled by default... " >&6; } +if ${libgcc_cv_powerpc_vsx+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +vector double dadd (vector double a, vector double b) { return a + b; } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libgcc_cv_powerpc_vsx=yes +else + libgcc_cv_powerpc_vsx=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_vsx" >&5 +$as_echo "$libgcc_cv_powerpc_vsx" >&6; } + CFLAGS="$CFLAGS -mabi=altivec -mcpu=power7 -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..47487d5be7bd 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -403,13 +403,20 @@ esac esac case ${host} in -# At present, we cannot turn -mfloat128 on via #pragma GCC target, so just -# 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. +# Test if the default compiler enables VSX. If it does not, we need to build +# the float128 bit support using -mcpu=power7 to enable the VSX instruction set. +# +# Also check if a new glibc is being used so that __builtin_cpu_supports can be +# used. powerpc*-*-linux*) saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -mabi=altivec -mvsx -mfloat128" + AC_CACHE_CHECK([if VSX is enabled by default], + [libgcc_cv_powerpc_vsx], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([vector double dadd (vector double a, vector double b) { return a + b; }])], + [libgcc_cv_powerpc_vsx=yes], + [libgcc_cv_powerpc_vsx=no])]) + CFLAGS="$CFLAGS -mabi=altivec -mcpu=power7 -mfloat128" AC_CACHE_CHECK([for PowerPC ISA 2.06 to build __float128 libraries], [libgcc_cv_powerpc_float128], [AC_COMPILE_IFELSE(