This is an archive of the discontinued LLVM Phabricator instance.

LangRef: Clarify behavior of minnum/maxnum
ClosedPublic

Authored by arsenm on Apr 20 2023, 4:41 AM.

Details

Summary

Make it clearer minnum(+0, +0) cannot return -0. Also remove
a note about the result always being quiet which is directly
contradicted by the following paragraph.

Diff Detail

Event Timeline

arsenm created this revision.Apr 20 2023, 4:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 4:41 AM
arsenm requested review of this revision.Apr 20 2023, 4:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 4:41 AM
Herald added a subscriber: wdng. · View Herald Transcript
foad added inline comments.Apr 20 2023, 5:20 AM
llvm/docs/LangRef.rst
14905

returns either one...

nikic added a subscriber: nikic.Apr 20 2023, 5:26 AM

Also remove a note about the result always being quiet which is directly contradicted by the following paragraph.

Where is the contradiction?

Also remove a note about the result always being quiet which is directly contradicted by the following paragraph.

Where is the contradiction?

The entire following paragraph. "Unlike the IEEE-754 2008 behavior, this does not distinguish between
signaling and quiet NaN inputs. If a target's implementation follows
the standard and returns a quiet NaN if either input is a signaling
NaN, the intrinsic lowering is responsible for quieting the inputs to
correctly return the non-NaN input (e.g. by using the equivalent of
`llvm.canonicalize`)."

This is not returning an "always quiet nan" and matches the libm behavior

nikic added a comment.Apr 20 2023, 5:32 AM

Also remove a note about the result always being quiet which is directly contradicted by the following paragraph.

Where is the contradiction?

The entire following paragraph. "Unlike the IEEE-754 2008 behavior, this does not distinguish between
signaling and quiet NaN inputs. If a target's implementation follows
the standard and returns a quiet NaN if either input is a signaling
NaN, the intrinsic lowering is responsible for quieting the inputs to
correctly return the non-NaN input (e.g. by using the equivalent of
`llvm.canonicalize`)."

This is not returning an "always quiet nan" and matches the libm behavior

Not sure I follow. If a NaN is returned, the NaN will always be quiet. The paragraph only clarifies that even if one input is SNaN a NaN will only be returned if the other input is NaN as well.

Not sure I follow. If a NaN is returned, the NaN will always be quiet.

This is distinguishing quiet and signaling nans. Not only is this inconsistent with the IR policy for unconstrained FP operations, it's not the behavior of libm fmin/fmax.

These intrinsics have the fmin/fmax behavior and were incorrectly named. The first sentence describes the IEEE754 behavior, and the second paragraph elaborates that they do not.

nikic added a comment.Apr 20 2023, 5:51 AM

Not sure I follow. If a NaN is returned, the NaN will always be quiet.

This is distinguishing quiet and signaling nans. Not only is this inconsistent with the IR policy for unconstrained FP operations, it's not the behavior of libm fmin/fmax.

These intrinsics have the fmin/fmax behavior and were incorrectly named. The first sentence describes the IEEE754 behavior, and the second paragraph elaborates that they do not.

I see, thanks for the explanation!

arsenm updated this revision to Diff 515301.Apr 20 2023, 6:12 AM
foad added inline comments.May 16 2023, 4:12 AM
llvm/docs/LangRef.rst
14905

ping

arsenm updated this revision to Diff 522540.May 16 2023, 4:28 AM
arsenm added inline comments.
llvm/docs/LangRef.rst
14905

Apparently I fixed this for max only

foad accepted this revision.May 16 2023, 4:30 AM
This revision is now accepted and ready to land.May 16 2023, 4:30 AM