public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work107)] Update type for __float128.
@ 2023-01-27  4:00 Michael Meissner
  0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2023-01-27  4:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6e41a4798ebc78c62d53e0c0fa0f9fe2eb9bd836

commit 6e41a4798ebc78c62d53e0c0fa0f9fe2eb9bd836
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Thu Jan 26 22:59:58 2023 -0500

    Update type for __float128.
    
    2022-01-26   Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            * config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Don't use long
            double as the base type for __float128 if long double is IEEE 128-bit.
            Use build_variant_type_copy to make a type based off of _Float128.

Diff:
---
 gcc/config/rs6000/rs6000-builtin.cc | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc
index 737a5c42bfb..873ae7ce875 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -730,25 +730,21 @@ rs6000_init_builtins (void)
 
   if (TARGET_FLOAT128_TYPE)
     {
-      if (TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128)
-	ieee128_float_type_node = long_double_type_node;
-      else
-	{
-	  /* For C we only need to register the __ieee128 name for
-	     it.  For C++, we create a distinct type which will mangle
-	     differently (u9__ieee128) vs. _Float128 (DF128_) and behave
-	     backwards compatibly.  */
-	  if (float128t_type_node == NULL_TREE)
-	    {
-	      float128t_type_node = make_node (REAL_TYPE);
-	      TYPE_PRECISION (float128t_type_node)
-		= TYPE_PRECISION (float128_type_node);
-	      layout_type (float128t_type_node);
-	      SET_TYPE_MODE (float128t_type_node,
-			     TYPE_MODE (float128_type_node));
-	    }
-	  ieee128_float_type_node = float128t_type_node;
-	}
+      /* For C we only need to register the __ieee128 name for it.  For C++, we
+	 create a distinct type which will mangle differently (u9__ieee128)
+	 vs. _Float128 (DF128_) and behave backwards compatibly.
+
+	 In the past we used the long double type if long double was IEEE
+	 128-bit.  This leads to differences if _Float128 and __float128 are
+	 not compatible types.  In particular, it showed up in generating
+	 signaling NaNs with __builtin_nansf128 and storing it into __float128,
+	 which at the time was based on long double.  Because they were
+	 different types, the signaling part of the NaN was lost in the
+	 conversion.  */
+      if (float128t_type_node == NULL_TREE)
+	float128t_type_node = build_variant_type_copy (float128_type_node);
+
+      ieee128_float_type_node = float128t_type_node;
       t = build_qualified_type (ieee128_float_type_node, TYPE_QUAL_CONST);
       lang_hooks.types.register_builtin_type (ieee128_float_type_node,
 					      "__ieee128");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-27  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27  4:00 [gcc(refs/users/meissner/heads/work107)] Update type for __float128 Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).