Skip to content

Commit dc326d0

Browse files
authored
[Clang][doc] -ffp-contract options and standard compliance (#127621)
We had an discussion about -ffp-contract, how it compared to GCC which defaults to fast, and standard compliance. Looking at our docs, most information is there, but this clarifies when this option is and isn't standard compliant.
1 parent e09fc39 commit dc326d0

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

clang/docs/UsersManual.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,19 +1681,27 @@ for more details.
16811681
permitted to produce more precise results than performing the same
16821682
operations separately.
16831683

1684-
The C standard permits intermediate floating-point results within an
1684+
The C and C++ standards permit intermediate floating-point results within an
16851685
expression to be computed with more precision than their type would
16861686
normally allow. This permits operation fusing, and Clang takes advantage
1687-
of this by default. This behavior can be controlled with the ``FP_CONTRACT``
1688-
and ``clang fp contract`` pragmas. Please refer to the pragma documentation
1689-
for a description of how the pragmas interact with this option.
1687+
of this by default (``on``). Fusion across statements is not compliant with
1688+
the C and C++ standards but can be enabled using ``-ffp-contract=fast``.
1689+
1690+
Fusion can be controlled with the ``FP_CONTRACT`` and ``clang fp contract``
1691+
pragmas. Please note that pragmas will be ingored with
1692+
``-ffp-contract=fast``, and refer to the pragma documentation for a
1693+
description of how the pragmas interact with the different ``-ffp-contract``
1694+
option values.
16901695

16911696
Valid values are:
16921697

1693-
* ``fast`` (fuse across statements disregarding pragmas, default for CUDA)
1694-
* ``on`` (fuse in the same statement unless dictated by pragmas, default for languages other than CUDA/HIP)
1695-
* ``off`` (never fuse)
1696-
* ``fast-honor-pragmas`` (fuse across statements unless dictated by pragmas, default for HIP)
1698+
* ``fast``: enable fusion across statements disregarding pragmas, breaking
1699+
compliance with the C and C++ standards (default for CUDA).
1700+
* ``on``: enable C and C++ standard complaint fusion in the same statement
1701+
unless dictated by pragmas (default for languages other than CUDA/HIP)
1702+
* ``off``: disable fusion
1703+
* ``fast-honor-pragmas``: fuse across statements unless dictated by pragmas
1704+
(default for HIP)
16971705

16981706
.. option:: -f[no-]honor-infinities
16991707

0 commit comments

Comments
 (0)