Skip to content

Commit a9c669c

Browse files
committed
[Clang][doc] -ffp-contract options and standard compliance
We had an internal discussion about -ffp-contract, how it compared to GCC which defaults to fast, and standard compliance. Looking at our docs, I think most information is there, but also thought it could be a little bit more explicit about when it is and isn't standard compliant. Let me know if you think this is an improvement or not; happy to abandon this if you think it is not helping much.
1 parent 059f044 commit a9c669c

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)