I have no more questions.

Thanks.

在 2022/11/11 下午1:29, Xi Ruoyao 写道:
Lulu:

So I think the code is correct:

+   (<lrint_allow_inexact>
+    || flag_fp_int_builtin_inexact
+    || !flag_trapping_math)"

<lrint_allow_inexact> is 1 for lrint, 0 for lceil and lfloor.  As N3054
says:

    The lrint and llrint functions provide floating-to-integer conversion as 
prescribed by IEC 60559.
    They round according to the current rounding direction. If the rounded 
value is outside the range of
    the return type, the numeric result is unspecified and the "invalid" 
floating-point exception is raised.
    When they raise no other floating-point exception and the result differs 
from the argument, they
    raise the "inexact" floating-point exception.
If flag_fp_int_builtin_inexact is set, we allow lceil and lfloor to
raise "inexact".

If flag_trapping_math is not set (it's set by default and can only be
unset explicitly with -fno-trapping-math: it's not even implied by -
ffast-math), we don't care about whether exceptions are raised or not.

So lceil and lfloor can be used if -ffp-int-builtin-inexact, or -fno-
trapping-math.

On Fri, 2022-11-11 at 00:07 +0000, Joseph Myers wrote:
On Thu, 10 Nov 2022, Xi Ruoyao via Gcc-patches wrote:

Joseph: can you confirm that -ftrapping-math allows floor and ceil to
raise inexact exception?  The man page currently says:

The default is -ffp-int-builtin-inexact, allowing the exception to be
raised, unless C2X or a later C standard is selected.  This option does
                                                        ^^^^^^^^^^^
nothing unless -ftrapping-math is in effect.

To me it's not very clear that "this option" stands for -fno-fp-int-
builtin-inexact or -ffp-int-builtin-inexact.
The -ftrapping-math option (which is on by default) means that we care
about whether operations raise exceptions: they should raise exceptions if
and only if the relevant standard permit them to do so.

The combination of -ftrapping-math with -fno-fp-int-builtin-inexact means
the listed built-in functions must not raise "inexact".

If -fno-trapping-math is used, then we don't care about whether exceptions
are raised or not (for any floating-point operations, not just those
functions).  So given -fno-trapping-math, there is no difference between
-fno-fp-int-builtin-inexact and -ffp-int-builtin-inexact.

If -ffp-int-builtin-inexact (default before C2X), we don't care about
whether those functions raise "inexact" (but still care about other
exceptions and exceptions for other operations, unless
-fno-trapping-math).

Reply via email to