From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 7066D3858403 for ; Sat, 25 Sep 2021 07:32:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7066D3858403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kZmwBrMqRxy0pTl2MHj7huXl/MqGXMkoDXk+lRfTHxI=; b=hV5Ofx8fSqLqCZdJwWUy+Ambpk wtImBDaL8bdOD+3nLHcyHAoGGsDSpGjtK5rCfPDyZRpJJveWmXJi+wzSussTxPCp6pQtyEIirlPZw Ss2zXkoFrBHOtcWhsXkOd35TBloM/Qs+O8l0O6puBR6vdLgNErH/zRnipGbpYqGzzgEiG7/OET8sQ wUUuxd0vTUvqA3Z409zHlF4AbtggrGeM646+DlXS5acXGwMoW8NJtNlviJwvTZ+51Ray9QWQs6hMN LsY7WxOpIHwZE5zDrS1mrD497BkDEfJeu4htAsshPnQD1QU8sPvQW19EvDXhIPM1EKol3l+0eCFSk msEqA5hw==; Received: from host86-186-213-65.range86-186.btcentralplus.com ([86.186.213.65]:51784 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mU2B5-0000MV-OM; Sat, 25 Sep 2021 03:32:56 -0400 From: "Roger Sayle" To: "'GCC Patches'" Cc: "'Eric Botcazou'" Subject: [PATCH] Make flag_trapping_math a non-binary Boolean. Date: Sat, 25 Sep 2021 08:32:54 +0100 Message-ID: <01b201d7b1df$8eadd7e0$ac0987a0$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01B3_01D7B1E7.F0735150" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adex3sT+8TlYQu6/QuWKuSb7481SWg== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Sep 2021 07:32:59 -0000 This is a multipart message in MIME format. ------=_NextPart_000_01B3_01D7B1E7.F0735150 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Normally Boolean options/flags in GCC take the values zero or one. This patch tweaks flag_trapping_math to take the values 0 or 65535. More accurately it introduces a new trapping_math_model enumeration in flag-types.h, and uses this to allow front-ends to (potentially) control which expressions may be constant folded at compile-time by the middle-end. Floating point/language experts may recognize these flags (bits) as being modelled upon (extended) FENV_ACCESS. This instalment simply introduces the necessary infrastructure without yet changing any functionality. The test "if (flag_trapping_math)" will remain perfectly valid (but pessimistic). The goal is to allow time for out-of-tree front-ends (modula-2, rust, etc.) to update themselves, if required, and to confirm that this change doesn't introduce problems for LTO, or elsewhere. This patch has been tested on x86_64-pc-linux-gnu with "make bootstrap" and "make -k check", all languages including Ada, with no new failures. Ok for mainline? 2021-09-25 Roger Sayle gcc/ChangeLog * flag-types.h (trapping_math_model): New enumeration (of bits) specifying possible floating-point (and integer) exceptions/traps. * common.opt (ftrapping-math): Specify UInteger and initialize to flag_trapping_math to TRAPPING_MATH_DEFAULT. * toplev.c (process_options): The option -fsignaling-nans should set flag_trapping_math to TRAPPING_MATH_DEFAULT. gcc/ada/ChangeLog * gcc-interface/misc.c (gnat_init_gcc_fp): Set flag_trapping_math to TRAPPING_MATH_DEFAULT (instead of 1) if S'Machine_Overflow. Roger -- ------=_NextPart_000_01B3_01D7B1E7.F0735150 Content-Type: text/plain; name="patcht.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patcht.txt" diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c=0A= index 96199bd..93cbc71 100644=0A= --- a/gcc/ada/gcc-interface/misc.c=0A= +++ b/gcc/ada/gcc-interface/misc.c=0A= @@ -451,7 +451,7 @@ gnat_init_gcc_fp (void)=0A= /* Assume that FP operations can trap if S'Machine_Overflow is true,=0A= but don't override the user if not. */=0A= if (Machine_Overflows_On_Target)=0A= - flag_trapping_math =3D 1;=0A= + flag_trapping_math =3D TRAPPING_MATH_DEFAULT;=0A= else if (!global_options_set.x_flag_trapping_math)=0A= flag_trapping_math =3D 0;=0A= }=0A= diff --git a/gcc/common.opt b/gcc/common.opt=0A= index b921f5e..314f9a7 100644=0A= --- a/gcc/common.opt=0A= +++ b/gcc/common.opt=0A= @@ -2750,7 +2750,7 @@ generate them instead of using descriptors.=0A= ; (user-visible) trap. This is the case, for example, in nonstop=0A= ; IEEE 754 arithmetic.=0A= ftrapping-math=0A= -Common Var(flag_trapping_math) Init(1) Optimization SetByCombined=0A= +Common Var(flag_trapping_math) Init(TRAPPING_MATH_DEFAULT) Optimization = SetByCombined UInteger=0A= Assume floating-point operations can trap.=0A= =0A= ftrapv=0A= diff --git a/gcc/flag-types.h b/gcc/flag-types.h=0A= index 5bd1f77..98b9ff0 100644=0A= --- a/gcc/flag-types.h=0A= +++ b/gcc/flag-types.h=0A= @@ -481,6 +481,33 @@ enum openacc_privatization=0A= OPENACC_PRIVATIZATION_NOISY=0A= };=0A= =0A= +/* Trapping math exception classes. */=0A= +enum trapping_math_model=0A= +{=0A= + TRAPPING_MATH_NONE =3D 0,=0A= + TRAPPING_MATH_QNANOP =3D 1UL << 0,=0A= + TRAPPING_MATH_SNANOP =3D 1UL << 1,=0A= + TRAPPING_MATH_QNANCMP =3D 1UL << 2,=0A= + TRAPPING_MATH_SNANCMP =3D 1UL << 3,=0A= + TRAPPING_MATH_INTCONV =3D 1UL << 4,=0A= + TRAPPING_MATH_SQRTNEG =3D 1UL << 5,=0A= + TRAPPING_MATH_LIBMFUN =3D 1UL << 6,=0A= + TRAPPING_MATH_FDIVZERO =3D 1UL << 7,=0A= + TRAPPING_MATH_IDIVZERO =3D 1UL << 8,=0A= + TRAPPING_MATH_FPDENORM =3D 1UL << 9,=0A= + TRAPPING_MATH_OVERFLOW =3D 1UL << 10,=0A= + TRAPPING_MATH_UNDERFLOW =3D 1UL << 11,=0A= + TRAPPING_MATH_INFDIVINF =3D 1UL << 12,=0A= + TRAPPING_MATH_INFSUBINF =3D 1UL << 13,=0A= + TRAPPING_MATH_INFMULZERO =3D 1UL << 14,=0A= + TRAPPING_MATH_ZERODIVZERO =3D 1UL << 15,=0A= +=0A= + TRAPPING_MATH_DEFAULT =3D (1UL << 16) - 1,=0A= +=0A= + TRAPPING_MATH_INEXACT =3D 1UL << 16,=0A= + TRAPPING_MATH_TRAPV =3D 1UL << 17=0A= +};=0A= +=0A= #endif=0A= =0A= #endif /* ! GCC_FLAG_TYPES_H */=0A= diff --git a/gcc/toplev.c b/gcc/toplev.c=0A= index 14d1335..6cd71cc 100644=0A= --- a/gcc/toplev.c=0A= +++ b/gcc/toplev.c=0A= @@ -1664,7 +1664,7 @@ process_options (void)=0A= =0A= /* The presence of IEEE signaling NaNs, implies all math can trap. */=0A= if (flag_signaling_nans)=0A= - flag_trapping_math =3D 1;=0A= + flag_trapping_math =3D TRAPPING_MATH_DEFAULT;=0A= =0A= /* We cannot reassociate if we want traps or signed zeros. */=0A= if (flag_associative_math && (flag_trapping_math || = flag_signed_zeros))=0A= ------=_NextPart_000_01B3_01D7B1E7.F0735150--