From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 86E283858D20; Fri, 27 Jan 2023 04:00:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86E283858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674792018; bh=J6Vn0S6tUpV7u/DduD+nDoZrkdJsgM/wjDBJLHzf12A=; h=From:To:Subject:Date:From; b=x66nwghwymsi8cwNV6pbT3HgH+ZLQ8K/VByjl+Pb7ktXXa7XgfHf+ibFTeKrZoffI zrUjGm8X+y6ngTu3gqCG4zLJ0clbzyXz1icPkpQyTJMYbCA+/KVHae2a5VcCUNEZnA 1XTfOCDWxmGbqbxCMHxAYgyf2FS1jqtaI96qebMM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Michael Meissner To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/work107)] Update type for __float128. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work107 X-Git-Oldrev: 146fffb36338595317131fc3d3371133baabb484 X-Git-Newrev: 6e41a4798ebc78c62d53e0c0fa0f9fe2eb9bd836 Message-Id: <20230127040018.86E283858D20@sourceware.org> Date: Fri, 27 Jan 2023 04:00:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6e41a4798ebc78c62d53e0c0fa0f9fe2eb9bd836 commit 6e41a4798ebc78c62d53e0c0fa0f9fe2eb9bd836 Author: Michael Meissner Date: Thu Jan 26 22:59:58 2023 -0500 Update type for __float128. 2022-01-26 Michael Meissner 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");