From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 28250384CB95 for ; Wed, 8 May 2024 07:19:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28250384CB95 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 28250384CB95 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715152797; cv=none; b=T/bfbfq5Qq2F5LDegoF1RZCRx3MVPoTtcAd60kDPPjjsHVNryw5S9wQfTVjzZ3vJMgAR1DkobDk0oZnykCawn/+PF0+McOYKdPdT+2MMUYhiqSnOdZ/2bQqfeLnrAne16O685wvjuA8Eh0trVsZJaiBXVfqSVzzH0biMwAGdBZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715152797; c=relaxed/simple; bh=jj6Cfuvzn+KuytB+ocCZpW1RGDHd4rutVM0ad7cKS8M=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Z9hmqEeehzAmdA5CykhIwGXsxpbw5zW0LZuawaWMA/odwsWpkrsOp3E8PY9Nq/3cKvPKXuWcCEjN08Zx8/HI5uzDN+pgWm5x/YmeYalW90tI3weRCm9d8gwwN0niwUFt5TUPiTpUzvh9U3q0ZLzKyn5hn7oydCIHQKCHUzSshpo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-51f0f6b613dso4878871e87.1 for ; Wed, 08 May 2024 00:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715152794; x=1715757594; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ui3AMc6JnPMUBnixV50EUdbzAARE8SdpoUwsz/RwUHs=; b=XEJRZlD87M4NtNdT1rRAOLB8beuKoqfqwOhADArYDBDKyj9/UBNuZFLNVpfBqpnabb S0yZvaU8fOFEy0OQsJ4IGIMq/lnmWAA4rvkeRCzqnUfr3zS9taRcAOpp/JCu7t/9ZUmR 2QJugjLhGXdS1DwXNbcjwCedSuxb+rmI11d9rI5QHuEPIRhDyzAB+T2DcM57DxDTDlbn PHDmeIPQeG5RMGD3soy5kDeTd+YweE691aDdh/lrF2FsoCMNPpK9pb+wimbE4FMMMB9k dCmZEiksGXmC2Avw2Kj6Y3GTNOZbtbMnka9WvxbieFllxWy0VAf3zwlgfEXj3L/1wVb3 DHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715152794; x=1715757594; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ui3AMc6JnPMUBnixV50EUdbzAARE8SdpoUwsz/RwUHs=; b=GwSqrbYIylo37bU19JJnnLqYurrFFV9FGg8+VjHcuiAATXZphbRnDtBxJjyPz9PdHH mzcahEs0skQbgWPUr6drxLtAwspci3fJxEkJF5fJVLdn7qtB3Hh/EUswL6ufpHy0ZuYx LN6xYYg/v9Yw6cHuurI5FvAf5QEvBJ6imIKZd4J1Rf0FP5xZqnxBdJyUlkFzrT6jfnxp 0bUs4RV3QR3WMBnVPbl0LHi20/s6OvLnOJBwviPa5UalryJYDdTUxPvF+IlcUSrVmgzC pP0UlEXHmXxZzvhvQta8++YmcIePPxPz+o/prk+Nw7YZ0x7EzqZioK+vEiTMvH3JgNdA sdrg== X-Forwarded-Encrypted: i=1; AJvYcCW/nSXz9t7FiICmkg8KNQbc22HOQDjcRIETCwptxPSjqfJy2sHqgk3AdTHaGd7W6myaJBAmB4sMIU+vMMQa3k0i8cDuQJV1yg== X-Gm-Message-State: AOJu0YyZLGXqai1zZObRej/0h9zZYtGrVccWGfJQfbp2UXuv7VaCyVLc acyNv+bxpX1YVvLvPvXWcxaL/0+fYpdLj92h7LrssFjPt7aLE3cd11QqHfgdM8Ll2Nizs5/0xjJ yITixtIFT1UK3xN7ZvsNjLaAVddjdwA== X-Google-Smtp-Source: AGHT+IFf6uEUN+wyFmp6QhLij3Oxdh/gMSVaQol3StId7lvILW1CTOKt1PnFYFaA8DocnaqmfGmLMVsw8Tso5sOFxLc= X-Received: by 2002:a05:6512:29a:b0:51f:5872:dd8c with SMTP id 2adb3069b0e04-5217c667325mr1037982e87.39.1715152794329; Wed, 08 May 2024 00:19:54 -0700 (PDT) MIME-Version: 1.0 References: <009201da97b2$325fc140$971f43c0$@nextmovesoftware.com> <001401da9c73$ff2bbec0$fd833c40$@nextmovesoftware.com> <00a201da9c97$78ab54e0$6a01fea0$@nextmovesoftware.com> In-Reply-To: From: Richard Biener Date: Wed, 8 May 2024 09:19:43 +0200 Message-ID: Subject: Re: [PATCH] PR middle-end/111701: signbit(x*x) vs -fsignaling-nans To: Joseph Myers Cc: Roger Sayle , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, May 7, 2024 at 10:44=E2=80=AFPM Joseph Myers = wrote: > > On Fri, 3 May 2024, Richard Biener wrote: > > > So what I do not necessarily agree with is that we need to preserve > > the multiplication with -fsignaling-nans. Do we consider a program doi= ng > > > > handler() { exit(0); } > > > > x =3D sNaN; > > ... > > sigaction(SIGFPE, ... handler) > > x*x; > > format_hard_drive(); > > > > and expecting the program to exit(0) rather than formating the hard-dis= k > > to be expecting something the C standard guarantees? And is it enough > > for the program to enable -fsignaling-nans for this? > > > > If so then the first and foremost bug is that 'x*x' doesn't have > > TREE_SIDE_EFFECTS > > set and thus we do not preserve it when optimizing __builtin_signbit ()= of it. > > Signaling NaNs don't seem relevant here. "Signal" means "set the > exception flag" - and 0 * Inf raises the same "invalid" exception flag as > sNaN * sNaN. Changing flow of control on an exception is outside the > scope of standard C and requires nonstandard extensions such as > feenableexcept. (At present -ftrapping-math covers both kinds of > exception handling - the default setting of a flag, and the nonstandard > change of flow of control.) So it's reasonable to require -fnon-call-exceptions (which now enables -fexceptions) and -fno-delete-dead-exceptions to have GCC preserve a change of control flow side-effect of x*x? We do not preserve FP exception bits set by otherwise unused operations, that is, we do not consider that side-effect to be observable even with -ftrapping-math. In fact I most uses of flag_trapping_math are related to a possible control flow side-effect of FP math. Exact preservation of FP exception flags will likely have to disable all FP optimization if one considers FE_INEXACT and FE_UNDERFLOW. Every time I try to make up my mind how to improve the situation for the user I'm only confusing myself :/ Richard. > -- > Joseph S. Myers > josmyers@redhat.com >