[2/5] Support IEEE 128-bit overload round_to_odd built-in functions.

Message ID YuIVM+APJ5g/Yzcv@toto.the-meissners.org
State New
Headers
Series IEEE 128-bit built-in overload support. |

Commit Message

Michael Meissner July 28, 2022, 4:48 a.m. UTC
  [PATCH 2/5] Support IEEE 128-bit overload round_to_odd built-in functions.

This patch adds support for overloading the IEEE 128-bit round to odd
built-in functions bewteeen KFmode and TFmode arguments.

I have tested these patches on a power10 that is running Fedora 36, which
defaults to using long doubles that are IEEE 128-bit.  I have built two
parallel GCC compilers, one that defaults to using IEEE 128-bit long doubles
and one that defaults to using IBM 128-bit long doubles.

I have compared the test results to the original compiler results, comparing a
modified GCC to the original compiler using an IEEE 128-bit long double
default, and also comparing a modified GCC to the original compiler using an
IBM 128-bit long double default.  In both cases, the results are the same.

I have also compared the compilers with the future patch in progress that does
switch the internal type handling.  Once those patches are installed, the
overload mechanism will insure the correct built-in is used.

Can I install this patch to the trunk, assuming I have installed the first
patch in the series?

2022-07-27   Michael Meissner  <meissner@linux.ibm.com>

gcc/

	* config/rs6000/rs6000-builtins.def
	(__builtin_addf128_round_to_odd_kf): Rename KFmode round to odd
	built-in functions with a KF suffix to allow overloading.
	(__builtin_divf128_round_to_odd_kf): Likewise.
	(__builtin_fmaf128_round_to_odd_kf): Likewise.
	(__builtin_mulf128_round_to_odd_kf): Likewise.
	(__builtin_sqrtf128_round_to_odd_kf): Likewise.
	(__builtin_subf128_round_to_odd_kf): Likewise.
	(__builtin_truncf128_round_to_odd_kf): Likewise.
	(__builtin_addf128_round_to_odd_tf): Add TFmode round to odd
	built-in functions.
	(__builtin_fmaf128_round_to_odd_tf): Likewise.
	(__builtin_mulf128_round_to_odd_tf): Likewise.
	(__builtin_sqrtf128_round_to_odd_tf): Likewise.
	(__builtin_subf128_round_to_odd_tf): Likewise.
	(__builtin_truncf128_round_to_odd_tf): Likewise.
	* config/rs6000/rs6000-overload.def
	(__builtin_addf128_round_to_odd): Make IEEE 128-bit round to odd
	built-in functions overloaded.
	(__builtin_divf128_round_to_odd): Likewise.
	(__builtin_fmaf128_round_to_odd): Likewise.
	(__builtin_mulf128_round_to_odd): Likewise.
	(__builtin_sqrtf128_round_to_odd): Likewise.
	(__builtin_subf128_round_to_odd): Likewise.
	(__builtin_truncf128_round_to_odd): Likewise.
---
 gcc/config/rs6000/rs6000-builtins.def | 58 ++++++++++++++++++++-------
 gcc/config/rs6000/rs6000-overload.def | 44 ++++++++++++++++++++
 2 files changed, 87 insertions(+), 15 deletions(-)
  

Patch

diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def
index defd7e25ffe..d72ff8cb7fe 100644
--- a/gcc/config/rs6000/rs6000-builtins.def
+++ b/gcc/config/rs6000/rs6000-builtins.def
@@ -2867,18 +2867,18 @@ 
 
 ; Builtins requiring hardware support for IEEE-128 floating-point.
 [ieee128-hw]
-  fpmath _Float128 __builtin_addf128_round_to_odd (_Float128, _Float128);
-    ADDF128_ODD addkf3_odd {}
+  fpmath _Float128 __builtin_addf128_round_to_odd_kf (_Float128, _Float128);
+    ADDF128_ODD_KF addkf3_odd {}
 
-  fpmath _Float128 __builtin_divf128_round_to_odd (_Float128, _Float128);
-    DIVF128_ODD divkf3_odd {}
+  fpmath _Float128 __builtin_divf128_round_to_odd_kf (_Float128, _Float128);
+    DIVF128_ODD_KF divkf3_odd {}
 
-  fpmath _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, \
-                                                   _Float128);
-    FMAF128_ODD fmakf4_odd {}
+  fpmath _Float128 __builtin_fmaf128_round_to_odd_kf (_Float128, _Float128, \
+						      _Float128);
+    FMAF128_ODD_KF fmakf4_odd {}
 
-  fpmath _Float128 __builtin_mulf128_round_to_odd (_Float128, _Float128);
-    MULF128_ODD mulkf3_odd {}
+  fpmath _Float128 __builtin_mulf128_round_to_odd_kf (_Float128, _Float128);
+    MULF128_ODD_KF mulkf3_odd {}
 
   const signed int __builtin_vsx_scalar_cmp_exp_qp_eq (_Float128, _Float128);
     VSCEQPEQ xscmpexpqp_eq_kf {}
@@ -2893,14 +2893,14 @@ 
       __builtin_vsx_scalar_cmp_exp_qp_unordered (_Float128, _Float128);
     VSCEQPUO xscmpexpqp_unordered_kf {}
 
-  fpmath _Float128 __builtin_sqrtf128_round_to_odd (_Float128);
-    SQRTF128_ODD sqrtkf2_odd {}
+  fpmath _Float128 __builtin_sqrtf128_round_to_odd_kf (_Float128);
+    SQRTF128_ODD_KF sqrtkf2_odd {}
 
-  fpmath _Float128 __builtin_subf128_round_to_odd (_Float128, _Float128);
-    SUBF128_ODD subkf3_odd {}
+  fpmath _Float128 __builtin_subf128_round_to_odd_kf (_Float128, _Float128);
+    SUBF128_ODD_KF subkf3_odd {}
 
-  fpmath double __builtin_truncf128_round_to_odd (_Float128);
-    TRUNCF128_ODD trunckfdf2_odd {}
+  fpmath double __builtin_truncf128_round_to_odd_kf (_Float128);
+    TRUNCF128_ODD_KF trunckfdf2_odd {}
 
   const signed long long __builtin_vsx_scalar_extract_expq (_Float128);
     VSEEQP xsxexpqp_kf {}
@@ -2924,6 +2924,34 @@ 
     VSTDCNQP xststdcnegqp_kf {}
 
 
+; Builtins requiring hardware support for IEEE-128 floating-point.  Long double
+; must use the IEEE 128-bit encoding.
+[ieee128-hw-ld]
+  fpmath long double __builtin_addf128_round_to_odd_tf (long double, long double);
+    ADDF128_ODD_TF addtf3_odd {ieeeld}
+
+  fpmath long double __builtin_divf128_round_to_odd_tf (long double,long double);
+    DIVF128_ODD_TF divtf3_odd {ieeeld}
+
+  fpmath long double __builtin_fmaf128_round_to_odd_tf (long double, \
+							long double, \
+							long double);
+    FMAF128_ODD_TF fmatf4_odd {ieeeld}
+
+  fpmath long double __builtin_mulf128_round_to_odd_tf (long double, \
+							long double);
+    MULF128_ODD_TF multf3_odd {ieeeld}
+
+  fpmath long double __builtin_sqrtf128_round_to_odd_tf (long double);
+    SQRTF128_ODD_TF sqrttf2_odd {ieeeld}
+
+  fpmath long double __builtin_subf128_round_to_odd_tf (long double, \
+							long double);
+    SUBF128_ODD_TF subtf3_odd {ieeeld}
+
+  fpmath double __builtin_truncf128_round_to_odd_tf (long double);
+    TRUNCF128_ODD_TF trunctfdf2_odd {ieeeld}
+
 
 ; Decimal floating-point builtins.
 [dfp]
diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def
index 44e2945aaa0..f406a16a882 100644
--- a/gcc/config/rs6000/rs6000-overload.def
+++ b/gcc/config/rs6000/rs6000-overload.def
@@ -6175,3 +6175,47 @@ 
     VUPKLSW  VUPKLSW_DEPR1
   vbll __builtin_vec_vupklsw (vbi);
     VUPKLSW  VUPKLSW_DEPR2
+
+[ADDF128_ODD, SKIP, __builtin_addf128_round_to_odd]
+  long double __builtin_addf128_round_to_odd (long double, long double);
+    ADDF128_ODD_TF
+  _Float128 __builtin_addf128_round_to_odd (_Float128, _Float128);
+    ADDF128_ODD_KF
+
+[DIVF128_ODD, SKIP, __builtin_divf128_round_to_odd]
+  long double __builtin_divf128_round_to_odd (long double, long double);
+    DIVF128_ODD_TF
+  _Float128 __builtin_divf128_round_to_odd (_Float128, _Float128);
+    DIVF128_ODD_KF
+
+[FMAF128_ODD, SKIP, __builtin_fmaf128_round_to_odd]
+  long double __builtin_fmaf128_round_to_odd (long double, long double, \
+					      long double);
+    FMAF128_ODD_TF
+  _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, \
+					    _Float128);
+    FMAF128_ODD_KF
+
+[MULF128_ODD, SKIP, __builtin_mulf128_round_to_odd]
+  long double __builtin_mulf128_round_to_odd (long double, long double);
+    MULF128_ODD_TF
+  _Float128 __builtin_mulf128_round_to_odd (_Float128, _Float128);
+    MULF128_ODD_KF
+
+[SQRTF128_ODD, SKIP, __builtin_sqrtf128_round_to_odd]
+  long double __builtin_sqrtf128_round_to_odd (long double);
+    SQRTF128_ODD_TF
+  _Float128 __builtin_sqrtf128_round_to_odd (_Float128);
+    SQRTF128_ODD_KF
+
+[SUBF128_ODD, SKIP, __builtin_subf128_round_to_odd]
+  long double __builtin_subf128_round_to_odd (long double, long double);
+    SUBF128_ODD_TF
+  _Float128 __builtin_subf128_round_to_odd (_Float128, _Float128);
+    SUBF128_ODD_KF
+
+[TRUNCF128_ODD, SKIP, __builtin_truncf128_round_to_odd]
+  long double __builtin_truncf128_round_to_odd (long double);
+    TRUNCF128_ODD_TF
+  _Float128 __builtin_truncf128_round_to_odd (_Float128);
+    TRUNCF128_ODD_KF