Skip to content

@llvm.maxnum.* does not handle signaling NaNs the same way as IEEE 754-2008 #27737

Open
@stoklund

Description

@stoklund
Bugzilla Link 27363
Version trunk
OS All
CC @asb,@frasercrmck,@sunfishcode,@lenary

Extended Description

The @​llvm.maxnum.* intrinsic is documented like this:

Follows the IEEE-754 semantics for maxNum, which also match for libm’s fmax.

If either operand is a NaN, returns the other non-NaN operand.
Returns NaN only if both operands are NaN.

If one operand is a signaling NaN, this behavior doesn't match IEEE 754-2008:

@llvm.maxnum.f64(1.0, qNaN) -> 1.0
@llvm.maxnum.f64(1.0, sNaN) -> 1.0

IEEE 754-2008:

maxNum(1.0, qNaN) -> 1.0
maxNum(1.0, sNaN) -> qNaN

I wonder if this changed in the 2008 revision?

The Aarch64 backend translates an fmax() library call to an fmaxnm instruction which has the 754-2008 semantics for signaling NaNs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions