[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 18 09:52:38 PST 2025
================
@@ -1681,19 +1681,25 @@ 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/C++ standard permits 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 non-C/C++ standard
+ compliant behavior and can be enabled (``fast``).
----------------
andykaylor wrote:
This last sentence is a bit unclear. I would suggest " Fusion across statements is not compliant with the C/C++ standard but can be enabled using ``-ffp-contract=fast``."
BTW, the C standard allows contraction of "expressions" saying that "a floating expression may be contracted" but the language gets imprecise if we start talking about "contraction across expressions" or "contractions across statements." I think saying "contractions across statements" is not allowed is more accurate, because we always have sub-expressions within what we're contracting. On the other hand, there are cases where we will not contract even within a statement. For example, an explicit cast in the middle of a statement prevents contraction (e.g. `x = c + (float)(a * b)` when a, b, and c are double). @AaronBallman can you suggest more precise wording?
https://github.com/llvm/llvm-project/pull/127621
More information about the cfe-commits
mailing list