@@ -16782,7 +16782,7 @@ versions of the intrinsics respect the exception behavior.
16782
16782
- qNaN, invalid exception
16783
16783
16784
16784
* - ``+0.0 vs -0.0``
16785
- - either one
16785
+ - +0.0(max)/-0.0(min)
16786
16786
- +0.0(max)/-0.0(min)
16787
16787
- +0.0(max)/-0.0(min)
16788
16788
@@ -16826,21 +16826,30 @@ type.
16826
16826
16827
16827
Semantics:
16828
16828
""""""""""
16829
+ Follows the semantics of minNum in IEEE-754-2008, except that -0.0 < +0.0 for the purposes
16830
+ of this intrinsic. As for signaling NaNs, per the minNum semantics, if either operand is sNaN,
16831
+ the result is qNaN. This matches the recommended behavior for the libm
16832
+ function ``fmin``, although not all implementations have implemented these recommended behaviors.
16833
+
16834
+ If either operand is a qNaN, returns the other non-NaN operand. Returns NaN only if both operands are
16835
+ NaN or if either operand is sNaN. Note that arithmetic on an sNaN doesn't consistently produce a qNaN,
16836
+ so arithmetic feeding into a minnum can produce inconsistent results. For example,
16837
+ ``minnum(fadd(sNaN, -0.0), 1.0)`` can produce qNaN or 1.0 depending on whether ``fadd`` is folded.
16829
16838
16830
- Follows the IEEE-754 semantics for minNum, except for handling of
16831
- signaling NaNs. This match's the behavior of libm's fmin .
16839
+ IEEE-754-2008 defines minNum, and it was removed in IEEE-754-2019. As the replacement, IEEE-754-2019
16840
+ defines :ref:`minimumNumber <i_minimumnum>` .
16832
16841
16833
- If either operand is a NaN, returns the other non-NaN operand. Returns
16834
- NaN only if both operands are NaN. If the operands compare equal,
16835
- returns either one of the operands. For example, this means that
16836
- fmin(+0.0, -0.0) returns either operand.
16842
+ If the intrinsic is marked with the nsz attribute, then the effect is as in the definition in C
16843
+ and IEEE-754-2008: the result of ``minnum(-0.0, +0.0)`` may be either -0.0 or +0.0.
16837
16844
16838
- Unlike the IEEE-754 2008 behavior, this does not distinguish between
16839
- signaling and quiet NaN inputs. If a target's implementation follows
16840
- the standard and returns a quiet NaN if either input is a signaling
16841
- NaN, the intrinsic lowering is responsible for quieting the inputs to
16842
- correctly return the non-NaN input (e.g. by using the equivalent of
16843
- ``llvm.canonicalize``).
16845
+ Some architectures, such as ARMv8 (FMINNM), LoongArch (fmin), MIPSr6 (min.fmt), PowerPC/VSX (xsmindp),
16846
+ have instructions that match these semantics exactly; thus it is quite simple for these architectures.
16847
+ Some architectures have similiar ones while they are not exact equivalent. Such as x86 implements ``MINPS``,
16848
+ which implements the semantics of C code ``a<b?a:b``: NUM vs qNaN always return qNaN. ``MINPS`` can be used
16849
+ if ``nsz`` and ``nnan`` are given.
16850
+
16851
+ For existing libc implementations, the behaviors of fmin may be quite different on sNaN and signed zero behaviors,
16852
+ even in the same release of a single libm implemention.
16844
16853
16845
16854
.. _i_maxnum:
16846
16855
@@ -16877,20 +16886,30 @@ type.
16877
16886
16878
16887
Semantics:
16879
16888
""""""""""
16880
- Follows the IEEE-754 semantics for maxNum except for the handling of
16881
- signaling NaNs. This matches the behavior of libm's fmax.
16889
+ Follows the semantics of maxNum in IEEE-754-2008, except that -0.0 < +0.0 for the purposes
16890
+ of this intrinsic. As for signaling NaNs, per the maxNum semantics, if either operand is sNaN,
16891
+ the result is qNaN. This matches the recommended behavior for the libm
16892
+ function ``fmax``, although not all implementations have implemented these recommended behaviors.
16893
+
16894
+ If either operand is a qNaN, returns the other non-NaN operand. Returns NaN only if both operands are
16895
+ NaN or if either operand is sNaN. Note that arithmetic on an sNaN doesn't consistently produce a qNaN,
16896
+ so arithmetic feeding into a maxnum can produce inconsistent results. For example,
16897
+ ``maxnum(fadd(sNaN, -0.0), 1.0)`` can produce qNaN or 1.0 depending on whether ``fadd`` is folded.
16882
16898
16883
- If either operand is a NaN, returns the other non-NaN operand. Returns
16884
- NaN only if both operands are NaN. If the operands compare equal,
16885
- returns either one of the operands. For example, this means that
16886
- fmax(+0.0, -0.0) returns either -0.0 or 0.0.
16899
+ IEEE-754-2008 defines maxNum, and it was removed in IEEE-754-2019. As the replacement, IEEE-754-2019
16900
+ defines :ref:`maximumNumber <i_maximumnum>`.
16887
16901
16888
- Unlike the IEEE-754 2008 behavior, this does not distinguish between
16889
- signaling and quiet NaN inputs. If a target's implementation follows
16890
- the standard and returns a quiet NaN if either input is a signaling
16891
- NaN, the intrinsic lowering is responsible for quieting the inputs to
16892
- correctly return the non-NaN input (e.g. by using the equivalent of
16893
- ``llvm.canonicalize``).
16902
+ If the intrinsic is marked with the nsz attribute, then the effect is as in the definition in C
16903
+ and IEEE-754-2008: the result of maxnum(-0.0, +0.0) may be either -0.0 or +0.0.
16904
+
16905
+ Some architectures, such as ARMv8 (FMAXNM), LoongArch (fmax), MIPSr6 (max.fmt), PowerPC/VSX (xsmaxdp),
16906
+ have instructions that match these semantics exactly; thus it is quite simple for these architectures.
16907
+ Some architectures have similiar ones while they are not exact equivalent. Such as x86 implements ``MAXPS``,
16908
+ which implements the semantics of C code ``a>b?a:b``: NUM vs qNaN always return qNaN. ``MAXPS`` can be used
16909
+ if ``nsz`` and ``nnan`` are given.
16910
+
16911
+ For existing libc implementations, the behaviors of fmin may be quite different on sNaN and signed zero behaviors,
16912
+ even in the same release of a single libm implemention.
16894
16913
16895
16914
.. _i_minimum:
16896
16915
@@ -19769,12 +19788,8 @@ The '``llvm.vector.reduce.fmax.*``' intrinsics do a floating-point
19769
19788
matches the element-type of the vector input.
19770
19789
19771
19790
This instruction has the same comparison semantics as the '``llvm.maxnum.*``'
19772
- intrinsic. That is, the result will always be a number unless all elements of
19773
- the vector are NaN. For a vector with maximum element magnitude 0.0 and
19774
- containing both +0.0 and -0.0 elements, the sign of the result is unspecified.
19775
-
19776
- If the intrinsic call has the ``nnan`` fast-math flag, then the operation can
19777
- assume that NaNs are not present in the input vector.
19791
+ intrinsic. If the intrinsic call has the ``nnan`` fast-math flag, then the
19792
+ operation can assume that NaNs are not present in the input vector.
19778
19793
19779
19794
Arguments:
19780
19795
""""""""""
@@ -19802,12 +19817,8 @@ The '``llvm.vector.reduce.fmin.*``' intrinsics do a floating-point
19802
19817
matches the element-type of the vector input.
19803
19818
19804
19819
This instruction has the same comparison semantics as the '``llvm.minnum.*``'
19805
- intrinsic. That is, the result will always be a number unless all elements of
19806
- the vector are NaN. For a vector with minimum element magnitude 0.0 and
19807
- containing both +0.0 and -0.0 elements, the sign of the result is unspecified.
19808
-
19809
- If the intrinsic call has the ``nnan`` fast-math flag, then the operation can
19810
- assume that NaNs are not present in the input vector.
19820
+ intrinsic. If the intrinsic call has the ``nnan`` fast-math flag, then the
19821
+ operation can assume that NaNs are not present in the input vector.
19811
19822
19812
19823
Arguments:
19813
19824
""""""""""
@@ -22086,7 +22097,7 @@ This is an overloaded intrinsic.
22086
22097
Overview:
22087
22098
"""""""""
22088
22099
22089
- Predicated floating-point IEEE-754 minNum of two vectors of floating-point values.
22100
+ Predicated floating-point IEEE-754-2008 minNum of two vectors of floating-point values.
22090
22101
22091
22102
22092
22103
Arguments:
@@ -22135,7 +22146,7 @@ This is an overloaded intrinsic.
22135
22146
Overview:
22136
22147
"""""""""
22137
22148
22138
- Predicated floating-point IEEE-754 maxNum of two vectors of floating-point values.
22149
+ Predicated floating-point IEEE-754-2008 maxNum of two vectors of floating-point values.
22139
22150
22140
22151
22141
22152
Arguments:
@@ -23434,10 +23445,7 @@ result type. If only ``nnan`` is set then the neutral value is ``-Infinity``.
23434
23445
23435
23446
This instruction has the same comparison semantics as the
23436
23447
:ref:`llvm.vector.reduce.fmax <int_vector_reduce_fmax>` intrinsic (and thus the
23437
- '``llvm.maxnum.*``' intrinsic). That is, the result will always be a number
23438
- unless all elements of the vector and the starting value are ``NaN``. For a
23439
- vector with maximum element magnitude ``0.0`` and containing both ``+0.0`` and
23440
- ``-0.0`` elements, the sign of the result is unspecified.
23448
+ '``llvm.maxnum.*``' intrinsic).
23441
23449
23442
23450
To ignore the start value, the neutral value can be used.
23443
23451
@@ -23504,10 +23512,7 @@ result type. If only ``nnan`` is set then the neutral value is ``+Infinity``.
23504
23512
23505
23513
This instruction has the same comparison semantics as the
23506
23514
:ref:`llvm.vector.reduce.fmin <int_vector_reduce_fmin>` intrinsic (and thus the
23507
- '``llvm.minnum.*``' intrinsic). That is, the result will always be a number
23508
- unless all elements of the vector and the starting value are ``NaN``. For a
23509
- vector with maximum element magnitude ``0.0`` and containing both ``+0.0`` and
23510
- ``-0.0`` elements, the sign of the result is unspecified.
23515
+ '``llvm.minnum.*``' intrinsic).
23511
23516
23512
23517
To ignore the start value, the neutral value can be used.
23513
23518
@@ -28179,7 +28184,7 @@ The third argument specifies the exception behavior as described above.
28179
28184
Semantics:
28180
28185
""""""""""
28181
28186
28182
- This function follows the IEEE-754 semantics for maxNum.
28187
+ This function follows the IEEE-754-2008 semantics for maxNum.
28183
28188
28184
28189
28185
28190
'``llvm.experimental.constrained.minnum``' Intrinsic
@@ -28211,7 +28216,7 @@ The third argument specifies the exception behavior as described above.
28211
28216
Semantics:
28212
28217
""""""""""
28213
28218
28214
- This function follows the IEEE-754 semantics for minNum.
28219
+ This function follows the IEEE-754-2008 semantics for minNum.
28215
28220
28216
28221
28217
28222
'``llvm.experimental.constrained.maximum``' Intrinsic
0 commit comments