Skip to content

CodeGen: Strengthen definition of F{MIN|MAX}NUM_IEEE nodes #85195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions llvm/docs/GlobalISel/GenericOpcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,32 @@ The return value of (FMAXNUM 0.0, -0.0) could be either 0.0 or -0.0.
G_FMINNUM_IEEE
^^^^^^^^^^^^^^

Perform floating-point minimum on two values, following the IEEE-754 2008
definition. This differs from FMINNUM in the handling of signaling NaNs. If one
input is a signaling NaN, returns a quiet NaN.
Perform floating-point minimum on two values, following IEEE-754
definitions. This differs from FMINNUM in the handling of signaling
NaNs.

If one input is a signaling NaN, returns a quiet NaN. This matches
IEEE-754 2008's minnum/maxnum for signaling NaNs (which differs from
2019).

These treat -0 as ordered less than +0, matching the behavior of
IEEE-754 2019's minimumNumber/maximumNumber (which was unspecified in
2008).

G_FMAXNUM_IEEE
^^^^^^^^^^^^^^

Perform floating-point maximum on two values, following the IEEE-754 2008
definition. This differs from FMAXNUM in the handling of signaling NaNs. If one
input is a signaling NaN, returns a quiet NaN.
Perform floating-point maximum on two values, following IEEE-754
definitions. This differs from FMAXNUM in the handling of signaling
NaNs.

If one input is a signaling NaN, returns a quiet NaN. This matches
IEEE-754 2008's minnum/maxnum for signaling NaNs (which differs from
2019).

These treat -0 as ordered less than +0, matching the behavior of
IEEE-754 2019's minimumNumber/maximumNumber (which was unspecified in
2008).

G_FMINIMUM
^^^^^^^^^^
Expand Down
14 changes: 10 additions & 4 deletions llvm/include/llvm/CodeGen/ISDOpcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,16 @@ enum NodeType {
FMINNUM,
FMAXNUM,

/// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
/// two values, following the IEEE-754 2008 definition. This differs from
/// FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
/// signaling NaN, returns a quiet NaN.
/// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or
/// maximumNumber on two values, following IEEE-754 definitions. This differs
/// from FMINNUM/FMAXNUM in the handling of signaling NaNs, and signed zero.
///
/// If one input is a signaling NaN, returns a quiet NaN. This matches
/// IEEE-754 2008's minnum/maxnum behavior for signaling NaNs (which differs
/// from 2019).
///
/// These treat -0 as ordered less than +0, matching the behavior of IEEE-754
/// 2019's minimumNumber/maximumNumber.
FMINNUM_IEEE,
FMAXNUM_IEEE,

Expand Down
15 changes: 11 additions & 4 deletions llvm/include/llvm/Target/GenericOpcodes.td
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,17 @@ def G_FMAXNUM : GenericInstruction {
let isCommutable = true;
}

// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
// two values, following the IEEE-754 2008 definition. This differs from
// FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
// signaling NaN, returns a quiet NaN.
// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or
// maximumNumber on two values, following IEEE-754 definitions. This
// differs from FMINNUM/FMAXNUM in the handling of signaling NaNs, and
// signed zero.
//
// If one input is a signaling NaN, returns a quiet NaN. This matches
// IEEE-754 2008's minnum/maxnum behavior for signaling NaNs (which
// differs from 2019).
//
// These treat -0 as ordered less than +0, matching the behavior of
// IEEE-754 2019's minimumNumber/maximumNumber.
def G_FMINNUM_IEEE : GenericInstruction {
let OutOperandList = (outs type0:$dst);
let InOperandList = (ins type0:$src1, type0:$src2);
Expand Down