[PATCH] middle-end: Fix PR middle-end/85811: Introduce tree_expr_maybe_nan_p et al.
Segher Boessenkool
segher@kernel.crashing.org
Mon Aug 17 23:12:39 GMT 2020
On Mon, Aug 17, 2020 at 10:31:08PM +0000, Joseph Myers wrote:
> On Sat, 15 Aug 2020, Segher Boessenkool wrote:
> > On Sat, Aug 15, 2020 at 12:10:42PM +0100, Roger Sayle wrote:
> > > I'll quote Joseph Myers (many thanks) who describes things clearly as:
> > > > (a) When both arguments are NaNs, the return value should be a qNaN,
> > > > but sometimes it is an sNaN if at least one argument is an sNaN.
> >
> > Where is this defined? I can't find it in C11, in 18661, and of course
> > it isn't what GCC does (it requires -fsignaling to even acknowledge the
> > existence of signaling NaNs :-) )
>
> The semantics of fmax and fmin are those of the maxNum and minNum
> operations in IEEE 754-2008 (that were removed in IEEE 754-2019); see the
> table of IEEE operation bindings that 18661-1 adds to Annex F.
>
> minNum(x, y) is the canonicalized number x if x < y, y if y < x, the
> canonicalized number if one operand is a number and the other a quiet
> NaN. Otherwise it is either x or y, canonicalized (this means results
> might differ among implementations). When either x or y is a
> signalingNaN, then the result is according to 6.2.
>
> maxNum(x, y) is the canonicalized number y if x < y, x if y < x, the
> canonicalized number if one operand is a number and the other a quiet
> NaN. Otherwise it is either x or y, canonicalized (this means results
> might differ among implementations). When either x or y is a
> signalingNaN, then the result is according to 6.2.
>
> where the relevant wording from 6.2 is
>
> Under default exception handling, any operation signaling an invalid
> operation exception and for which a floating-point result is to be
> delivered shall deliver a quiet NaN.
>
> Signaling NaNs shall be reserved operands that, under default exception
> handling, signal the invalid operation exception (see 7.2) for every
> general-computational and signaling-computational operation except for
> the conversions described in 5.12. For non-default treatment, see 8.
>
> (and maxNum and minNum are in 5.3 "Homogeneous general-computational
> operations").
Ah, so "When both arguments are NaNs, the return value should be a qNaN"
means the QNaN corresponding to eother x or y. I see, thanks!
Segher
More information about the Gcc-patches
mailing list