[2/3] Allow __ibm128 with -msoft-float (PR target/105334)

Message ID Yv6x+lPBrQoAz05P@toto.the-meissners.org
State New
Headers
Series Improvements to __ibm128 on PowerPC |

Commit Message

Michael Meissner Aug. 18, 2022, 9:41 p.m. UTC
  Allow __ibm128 with -msoft-float (PR target/105334)

This patch allows __ibm128 to be used on systems with software floating point
enabled.  Previously, we required hardware floating point to be enabled to use
__ibm128 keyword and the __ibm128 built-in functions.  This patch fixes PR
target/105334.

I have tested this patch on the following systems:

    1)	LE Power10 using --with-cpu=power10 --with-long-double-format=ieee
    2)	LE Power10 using --with-cpu=power9  --with-long-double-format=ibm
    3)	LE Power10 using --with-cpu=power8  --with-long-double-format=ibm
    4)	LE Power10 using --with-cpu=power10 --with-long-double-format=ibm
    5)	LE Power9  using --with-cpu=power9  --with-long-double-format=ibm
    6)	BE Power8  using --with-cpu=power8  --with-long-double-format=ibm
    7)	BE Power8  using --with-cpu=power5  --with-long-double-format=ibm

There were no regressions in the build or in the tests.  On the power10 with
long double using the IEEE 128-bit format, pr105334.c now runs where it
previously failed.

Can I check this patch into the trunk?

Did we want to backport this to earlier GCC releases?

2022-08-17   Michael Meissner  <meissner@linux.ibm.com>

gcc/

	PR target/105334
	* config/rs6000/rs6000.cc (init_float128_ibm): Do not require hardware
	floating point for the IBM 128-bit floating point comparison functions.
	* config/rs6000/rs6000.h (FLOAT128_IBM_P): Do not require hardware
	floating point to enable recognizing IBM 128-bit floating point modes.
---
 gcc/config/rs6000/rs6000.cc | 37 +++++++++++++++++--------------------
 gcc/config/rs6000/rs6000.h  |  2 +-
 2 files changed, 18 insertions(+), 21 deletions(-)
  

Patch

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 39527ce9bbc..a6ec4c71ac0 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -10913,26 +10913,23 @@  init_float128_ibm (machine_mode mode)
       set_optab_libfunc (smul_optab, mode, "__gcc_qmul");
       set_optab_libfunc (sdiv_optab, mode, "__gcc_qdiv");
 
-      if (!TARGET_HARD_FLOAT)
-	{
-	  set_optab_libfunc (neg_optab, mode, "__gcc_qneg");
-	  set_optab_libfunc (eq_optab, mode, "__gcc_qeq");
-	  set_optab_libfunc (ne_optab, mode, "__gcc_qne");
-	  set_optab_libfunc (gt_optab, mode, "__gcc_qgt");
-	  set_optab_libfunc (ge_optab, mode, "__gcc_qge");
-	  set_optab_libfunc (lt_optab, mode, "__gcc_qlt");
-	  set_optab_libfunc (le_optab, mode, "__gcc_qle");
-	  set_optab_libfunc (unord_optab, mode, "__gcc_qunord");
-
-	  set_conv_libfunc (sext_optab, mode, SFmode, "__gcc_stoq");
-	  set_conv_libfunc (sext_optab, mode, DFmode, "__gcc_dtoq");
-	  set_conv_libfunc (trunc_optab, SFmode, mode, "__gcc_qtos");
-	  set_conv_libfunc (trunc_optab, DFmode, mode, "__gcc_qtod");
-	  set_conv_libfunc (sfix_optab, SImode, mode, "__gcc_qtoi");
-	  set_conv_libfunc (ufix_optab, SImode, mode, "__gcc_qtou");
-	  set_conv_libfunc (sfloat_optab, mode, SImode, "__gcc_itoq");
-	  set_conv_libfunc (ufloat_optab, mode, SImode, "__gcc_utoq");
-	}
+      set_optab_libfunc (neg_optab, mode, "__gcc_qneg");
+      set_optab_libfunc (eq_optab, mode, "__gcc_qeq");
+      set_optab_libfunc (ne_optab, mode, "__gcc_qne");
+      set_optab_libfunc (gt_optab, mode, "__gcc_qgt");
+      set_optab_libfunc (ge_optab, mode, "__gcc_qge");
+      set_optab_libfunc (lt_optab, mode, "__gcc_qlt");
+      set_optab_libfunc (le_optab, mode, "__gcc_qle");
+      set_optab_libfunc (unord_optab, mode, "__gcc_qunord");
+
+      set_conv_libfunc (sext_optab, mode, SFmode, "__gcc_stoq");
+      set_conv_libfunc (sext_optab, mode, DFmode, "__gcc_dtoq");
+      set_conv_libfunc (trunc_optab, SFmode, mode, "__gcc_qtos");
+      set_conv_libfunc (trunc_optab, DFmode, mode, "__gcc_qtod");
+      set_conv_libfunc (sfix_optab, SImode, mode, "__gcc_qtoi");
+      set_conv_libfunc (ufix_optab, SImode, mode, "__gcc_qtou");
+      set_conv_libfunc (sfloat_optab, mode, SImode, "__gcc_itoq");
+      set_conv_libfunc (ufloat_optab, mode, SImode, "__gcc_utoq");
     }
   else
     {
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 813ec696c0d..f58f5f3f355 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -337,7 +337,7 @@  extern const char *host_detect_local_cpu (int argc, const char **argv);
 #define FLOAT128_IBM_P(MODE)						\
   ((!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128				\
     && ((MODE) == TFmode || (MODE) == TCmode))				\
-   || (TARGET_HARD_FLOAT && ((MODE) == IFmode || (MODE) == ICmode)))
+   || ((MODE) == IFmode || (MODE) == ICmode))
 
 /* Helper macros to say whether a 128-bit floating point type can go in a
    single vector register, or whether it needs paired scalar values.  */