public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math'
@ 2022-07-19 12:23 Maciej W. Rozycki
  2022-07-20  7:19 ` Richard Biener
  2022-07-27 22:45 ` Joseph Myers
  0 siblings, 2 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-07-19 12:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph Myers

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.

	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. <https://gcc.gnu.org/pipermail/gcc-patches/2022-July/597767.html>.

  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math'
  2022-07-19 12:23 [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math' Maciej W. Rozycki
@ 2022-07-20  7:19 ` Richard Biener
  2022-07-27 22:45 ` Joseph Myers
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Biener @ 2022-07-20  7:19 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: GCC Patches, Joseph Myers

On Tue, Jul 19, 2022 at 2:24 PM Maciej W. Rozycki <macro@embecosm.com> 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. <https://gcc.gnu.org/pipermail/gcc-patches/2022-July/597767.html>.
>
>   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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math'
  2022-07-19 12:23 [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math' Maciej W. Rozycki
  2022-07-20  7:19 ` Richard Biener
@ 2022-07-27 22:45 ` Joseph Myers
  2022-07-28 13:22   ` Maciej W. Rozycki
  1 sibling, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2022-07-27 22:45 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches

On Tue, 19 Jul 2022, 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.
> 
> 	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'.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math'
  2022-07-27 22:45 ` Joseph Myers
@ 2022-07-28 13:22   ` Maciej W. Rozycki
  0 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-07-28 13:22 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches

On Wed, 27 Jul 2022, Joseph Myers wrote:

> > 	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'.
> 
> OK.

 I have committed this change, thank you for your review.

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-28 13:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 12:23 [PATCH] doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math' Maciej W. Rozycki
2022-07-20  7:19 ` Richard Biener
2022-07-27 22:45 ` Joseph Myers
2022-07-28 13:22   ` Maciej W. Rozycki

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).