From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id DFF383858C00 for ; Wed, 20 Jul 2022 07:19:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFF383858C00 Received: by mail-ej1-x62e.google.com with SMTP id tk8so20089401ejc.7 for ; Wed, 20 Jul 2022 00:19:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ost4+I0ladmnULxJNVVBOj3+ehIZvlhRBNSLsqbKDOs=; b=cItkja2dRX884KpkBRr5G/XecOYBnsXuLUxhS2ikEyr1Q/Ngxe00HP63NgICERm1KT kxOaIoYH+B09tJ8NXm823s3IJar+XI8qB3fPJjlDnqfnb0eU73bdC99h9ck83ErviARA WVBXZ2ANlAeIDgUCcmM6EEWEawssLXf7i5ybdHpqqu76Lmg9W/PoJ5caUUY7PWpldedg DhJrOdiSICvqdjvVUlo+sCa3rgDdUyAy1X/y4pPzceAb9w3Y5T6qGVGfpR0HG0ZgGoEj YwviYin552mpd2dkV85PNVYs1QkTnQmerEKcehedR0+vg/s3GU5alBV4cIHGznYUzirG z46g== X-Gm-Message-State: AJIora+G6hraRu8y5EYgqerCvKZWe6ryVNrrZXKdM95pct7vLixtFFQe N2pU6YFOUYtDZlsiX53PgkSKqu6qhPGc9FSxOTs= X-Google-Smtp-Source: AGRyM1s2sgXtvEvtwLAy2ar58ewR/JegLZDJw79duo9lUjbFZpDdcJ4kfSiUibg9XGXgvxdFwuuqBmZfZb9TQhVLbIg= X-Received: by 2002:a17:907:608d:b0:72f:191b:7625 with SMTP id ht13-20020a170907608d00b0072f191b7625mr19338507ejc.754.1658301589159; Wed, 20 Jul 2022 00:19:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Wed, 20 Jul 2022 09:19:36 +0200 Message-ID: Subject: Re: [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math' To: "Maciej W. Rozycki" Cc: GCC Patches , Joseph Myers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Wed, 20 Jul 2022 07:19:52 -0000 On Tue, Jul 19, 2022 at 2:24 PM Maciej W. Rozycki wrote: > > Our documentation indicates that it is the `-frounding-math' invocation > option that controls whether we respect what the FENV_ACCESS pragma > would imply, should we implement it, regarding the floating point > environment. It is only a part of the picture however, because the > `-ftrapping-math' invocation option also affects how we handle said > environment. Clarify that in the description of both options then, as > well as the FENV_ACCESS pragma itself. I'll let Joseph comment on the patch since he wrote multiple times how things should behave (I think it's OK). We might want to split -ftrapping-math into -fieee-exceptions (whether we care about the IEEE exception state) and -ftrapping-math (we assume the user might have enabled the CPU to trap on IEEE exceptions). It might be also worth to document that any inspection/modification of the FP state during asynchronous events is not supported. It was already mentioned that our default of -ftrapping-math -fno-rounding-math doesn't make much sense given we don't really support inspecting the IEEE exceptions state but -ftrapping-math makes us only careful about CPU traps caused by IEEE exceptions which isn't the default behavior anywhere (and should be discouraged in general). Together with better documentation I'd support trying to change the default of this for GCC 13. > gcc/ > * doc/implement-c.texi (Floating point implementation): Mention > `-fno-trapping-math' in the context of FENV_ACCESS pragma. > * doc/invoke.texi (Optimize Options): Clarify FENV_ACCESS pragma > implication in the descriptions of `-fno-trapping-math' and > `-frounding-math'. > --- > Hi, > > Discovered in the course of investigating RISC-V unordered comparisons, > c.f. . > > Maciej > --- > gcc/doc/implement-c.texi | 3 ++- > gcc/doc/invoke.texi | 8 +++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > gcc-doc-fenv-access-trapping.diff > Index: gcc/gcc/doc/implement-c.texi > =================================================================== > --- gcc.orig/gcc/doc/implement-c.texi > +++ gcc/gcc/doc/implement-c.texi > @@ -339,7 +339,8 @@ This is subject to change. > 7.6.1).} > > This pragma is not implemented, but the default is to ``off'' unless > -@option{-frounding-math} is used in which case it is ``on''. > +@option{-frounding-math} is used and @option{-fno-trapping-math} is not > +in which case it is ``on''. > > @item > @cite{Additional floating-point exceptions, rounding modes, environments, > Index: gcc/gcc/doc/invoke.texi > =================================================================== > --- gcc.orig/gcc/doc/invoke.texi > +++ gcc/gcc/doc/invoke.texi > @@ -13513,6 +13513,11 @@ math functions. > > The default is @option{-ftrapping-math}. > > +Future versions of GCC may provide finer control of this setting > +using C99's @code{FENV_ACCESS} pragma. This command-line option > +will be used along with @option{-frounding-math} to specify the > +default state for @code{FENV_ACCESS}. > + > @item -frounding-math > @opindex frounding-math > Disable transformations and optimizations that assume default floating-point > @@ -13531,7 +13536,8 @@ This option is experimental and does not > disable all GCC optimizations that are affected by rounding mode. > Future versions of GCC may provide finer control of this setting > using C99's @code{FENV_ACCESS} pragma. This command-line option > -will be used to specify the default state for @code{FENV_ACCESS}. > +will be used along with @option{-ftrapping-math} to specify the > +default state for @code{FENV_ACCESS}. > > @item -fsignaling-nans > @opindex fsignaling-nans