@@ -3584,16 +3584,31 @@ LLVM floating-point types fall into two categories:
35843584- The remaining types, which do not directly correspond to a standard IEEE
35853585 format.
35863586
3587- For types that do correspond to an IEEE format, LLVM IR float operations behave
3588- like the corresponding operations in IEEE-754, with two exceptions: LLVM makes
3589- :ref:`specific assumptions about the state of the floating-point environment
3590- <floatenv>` and it implements :ref:`different rules for operations that return
3591- NaN values <floatnan>`.
3587+ For floating-point operations acting on types with a corresponding IEEE format,
3588+ unless otherwise specified the value returned by that operation matches that of
3589+ the corresponding IEEE-754 operation executed in the :ref:`default
3590+ floating-point environment <floatenv>`, except that the behavior of NaN results
3591+ is instead :ref:`as specified here <floatnan>`. (This statement concerns only
3592+ the returned *value*; we make no statement about status flags or
3593+ traps/exceptions.) In particular, a floating-point instruction returning a
3594+ non-NaN value is guaranteed to always return the same bit-identical result on
3595+ all machines and optimization levels.
3596+
3597+ This means that optimizations and backends may not change the observed bitwise
3598+ result of these operations in any way (unless NaNs are returned), and frontends
3599+ can rely on these operations providing perfectly rounded results as described in
3600+ the standard.
3601+
3602+ Various flags and attributes can alter the behavior of these operations and thus
3603+ make them not bit-identical across machines and optimization levels any more:
3604+ most notably, the :ref:`fast-math flags <fastmath>` as well as the ``strictfp``
3605+ and ``denormal-fp-math`` attributes. See their corresponding documentation for
3606+ details.
35923607
3593- This means that optimizations and backends cannot change the precision of these
3594- operations (unless there are fast-math flags), and frontends can rely on these
3595- operations deterministically providing perfectly rounded results as described
3596- in the standard (except when a NaN is returned) .
3608+ If the compiled code is executed in a non-default floating-point environment
3609+ (this includes non-standard behavior such as subnormal flushing), the result is
3610+ typically undefined behavior unless attributes like ``strictfp`` and
3611+ ``denormal-fp-math`` or :ref:`constrained intrinsics <constrainedfp>` are used .
35973612
35983613.. _floatenv:
35993614
@@ -3633,9 +3648,9 @@ representation and never change anything except possibly for the sign bit.
36333648
36343649Floating-point math operations that return a NaN are an exception from the
36353650general principle that LLVM implements IEEE-754 semantics. Unless specified
3636- otherwise, the following rules apply when a NaN value is returned: the result
3637- has a non-deterministic sign; the quiet bit and payload are
3638- non-deterministically chosen from the following set of options:
3651+ otherwise, the following rules apply whenever the IEEE-754 semantics say that a
3652+ NaN value is returned: the result has a non-deterministic sign; the quiet bit
3653+ and payload are non-deterministically chosen from the following set of options:
36393654
36403655- The quiet bit is set and the payload is all-zero. ("Preferred NaN" case)
36413656- The quiet bit is set and the payload is copied from any input operand that is
0 commit comments