Skip to content

[Clang][doc] -ffp-contract options and standard compliance #127621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1681,19 +1681,27 @@ for more details.
permitted to produce more precise results than performing the same
operations separately.

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

Fusion can be controlled with the ``FP_CONTRACT`` and ``clang fp contract``
pragmas. Please note that pragmas will be ingored with
``-ffp-contract=fast``, and refer to the pragma documentation for a
description of how the pragmas interact with the different ``-ffp-contract``
option values.

Valid values are:

* ``fast`` (fuse across statements disregarding pragmas, default for CUDA)
* ``on`` (fuse in the same statement unless dictated by pragmas, default for languages other than CUDA/HIP)
* ``off`` (never fuse)
* ``fast-honor-pragmas`` (fuse across statements unless dictated by pragmas, default for HIP)
* ``fast``: enable fusion across statements disregarding pragmas, breaking
compliance with the C and C++ standards (default for CUDA).
* ``on``: enable C and C++ standard complaint fusion in the same statement
unless dictated by pragmas (default for languages other than CUDA/HIP)
* ``off``: disable fusion
* ``fast-honor-pragmas``: fuse across statements unless dictated by pragmas
(default for HIP)

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

Expand Down