Skip to content

Commit dc9664a

Browse files
authored
CodeGen: Strengthen definition of F{MIN|MAX}NUM_IEEE nodes (#85195)
Previously these were declared as having the 2008 behavior, with underspecified signed zero handling. Currently, AMDGPU, PPC and LoongArch mark these as legal. The AMDGPU and PPC instructions respect the signed zero behavior. The LoongArch documentation doesn't state, but I'm assuming it also does.
1 parent 57b2679 commit dc9664a

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

llvm/docs/GlobalISel/GenericOpcode.rst

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,32 @@ The return value of (FMAXNUM 0.0, -0.0) could be either 0.0 or -0.0.
521521
G_FMINNUM_IEEE
522522
^^^^^^^^^^^^^^
523523

524-
Perform floating-point minimum on two values, following the IEEE-754 2008
525-
definition. This differs from FMINNUM in the handling of signaling NaNs. If one
526-
input is a signaling NaN, returns a quiet NaN.
524+
Perform floating-point minimum on two values, following IEEE-754
525+
definitions. This differs from FMINNUM in the handling of signaling
526+
NaNs.
527+
528+
If one input is a signaling NaN, returns a quiet NaN. This matches
529+
IEEE-754 2008's minnum/maxnum for signaling NaNs (which differs from
530+
2019).
531+
532+
These treat -0 as ordered less than +0, matching the behavior of
533+
IEEE-754 2019's minimumNumber/maximumNumber (which was unspecified in
534+
2008).
527535

528536
G_FMAXNUM_IEEE
529537
^^^^^^^^^^^^^^
530538

531-
Perform floating-point maximum on two values, following the IEEE-754 2008
532-
definition. This differs from FMAXNUM in the handling of signaling NaNs. If one
533-
input is a signaling NaN, returns a quiet NaN.
539+
Perform floating-point maximum on two values, following IEEE-754
540+
definitions. This differs from FMAXNUM in the handling of signaling
541+
NaNs.
542+
543+
If one input is a signaling NaN, returns a quiet NaN. This matches
544+
IEEE-754 2008's minnum/maxnum for signaling NaNs (which differs from
545+
2019).
546+
547+
These treat -0 as ordered less than +0, matching the behavior of
548+
IEEE-754 2019's minimumNumber/maximumNumber (which was unspecified in
549+
2008).
534550

535551
G_FMINIMUM
536552
^^^^^^^^^^

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,16 @@ enum NodeType {
971971
FMINNUM,
972972
FMAXNUM,
973973

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

llvm/include/llvm/Target/GenericOpcodes.td

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,17 @@ def G_FMAXNUM : GenericInstruction {
795795
let isCommutable = true;
796796
}
797797

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

0 commit comments

Comments
 (0)