Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12039350
D67517.diff
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 30, 7:13 PM
Size
7 KB
Mime Type
text/xpatch; charset=utf8
Expires
Sun, May 31, 7:13 PM (1 d)
Engine
blob
Format
Raw Data
Handle
6253118
Attached To
D67517: Create UsersManual section entitled 'Controlling Floating Point Behavior'
D67517.diff
View Options
Index: cfe/trunk/docs/UsersManual.rst
===================================================================
 cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ 1128,6 +1128,185 @@
and the precompiled header cannot be generated after headers have been
installed.
+.. _controllingfpbehavior:
+
+Controlling Floating Point Behavior
+
+
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
+
+.. option:: ffastmath
+
+ Enable fastmath mode. This option lets the
+ compiler make aggressive, potentiallylossy assumptions about
+ floatingpoint math. These include:
+
+ * Floatingpoint math obeys regular algebraic rules for real numbers (e.g.
+ ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
+ ``(a + b) * c == a * c + b * c``),
+ * Operands to floatingpoint operations are not equal to ``NaN`` and
+ ``Inf``, and
+ * ``+0`` and ``0`` are interchangeable.
+
+ ``ffastmath`` also defines the ``__FAST_MATH__`` preprocessor
+ macro. Some math libraries recognize this macro and change their behavior.
+ With the exception of ``ffpcontract=fast``, using any of the options
+ below to disable any of the individual optimizations in ``ffastmath``
+ will cause ``__FAST_MATH__`` to no longer be set.
+
+ This option implies:
+
+ * ``fnohonorinfinities``
+
+ * ``fnohonornans``
+
+ * ``fnomatherrno``
+
+ * ``ffinitemath``
+
+ * ``fassociativemath``
+
+ * ``freciprocalmath``
+
+ * ``fnosignedzeros``
+
+ * ``fnotrappingmath``
+
+ * ``ffpcontract=fast``
+
+.. option:: fdenormalfpmath=<value>
+
+ Select which denormal numbers the code is permitted to require.
+
+ Valid values are:
+
+ * ``ieee``  IEEE 754 denormal numbers
+ * ``preservesign``  the sign of a flushedtozero number is preserved in the sign of 0
+ * ``positivezero``  denormals are flushed to positive zero
+
+ Defaults to ``ieee``.
+
+.. _opt_fstrictfloatcastoverflow:
+
+**f[no]strictfloatcastoverflow**
+
+ When a floatingpoint value is not representable in a destination integer
+ type, the code has undefined behavior according to the language standard.
+ By default, Clang will not guarantee any particular result in that case.
+ With the 'nostrict' option, Clang attempts to match the overflowing behavior
+ of the target's native floattoint conversion instructions.
+
+.. _opt_fmatherrno:
+
+**f[no]matherrno**
+
+ Require math functions to indicate errors by setting errno.
+ The default varies by ToolChain. ``fnomatherrno`` allows optimizations
+ that might cause standard C math functions to not set ``errno``.
+ For example, on some systems, the math function ``sqrt`` is specified
+ as setting ``errno`` to ``EDOM`` when the input is negative. On these
+ systems, the compiler cannot normally optimize a call to ``sqrt`` to use
+ inline code (e.g. the x86 ``sqrtsd`` instruction) without additional
+ checking to ensure that ``errno`` is set appropriately.
+ ``fnomatherrno`` permits these transformations.
+
+ On some targets, math library functions never set ``errno``, and so
+ ``fnomatherrno`` is the default. This includes most BSDderived
+ systems, including Darwin.
+
+.. _opt_ftrappingmath:
+
+**f[no]trappingmath**
+
+ ``fnotrappingmath`` allows optimizations that assume that
+ floating point operations cannot generate traps such as dividebyzero,
+ overflow and underflow. Defaults to ``ftrappingmath``.
+ Currently this option has no effect.
+
+.. option:: ffpcontract=<value>
+
+ Specify when the compiler is permitted to form fused floatingpoint
+ operations, such as fused multiplyadd (FMA). Fused operations are
+ permitted to produce more precise results than performing the same
+ operations separately.
+
+ The C standard permits intermediate floatingpoint 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`` pragma. Please refer to the pragma documentation for a
+ description of how the pragma interacts with this option.
+
+ Valid values are:
+
+ * ``fast`` (everywhere)
+ * ``on`` (according to FP_CONTRACT pragma, default)
+ * ``off`` (never fuse)
+
+.. _opt_fhonorinfinities:
+
+**f[no]honorinfinities**
+
+ If both ``fnohonorinfinities`` and ``fnohonornans`` are used,
+ has the same effect as specifying ``ffinitemath``.
+
+.. _opt_fhonornans:
+
+**f[no]honornans**
+
+ If both ``fnohonorinfinities`` and ``fnohonornans`` are used,
+ has the same effect as specifying ``ffinitemath``.
+
+.. _opt_fsignedzeros:
+
+**f[no]signedzeros**
+
+ Allow optimizations that ignore the sign of floating point zeros.
+ Defaults to ``fnosignedzeros``.
+
+.. _opt_fassociativemath:
+
+**f[no]associativemath**
+
+ Allow floating point operations to be reassociated.
+ Defaults to ``fnoassociativemath``.
+
+.. _opt_freciprocalmath:
+
+**f[no]reciprocalmath**
+
+ Allow division operations to be transformed into multiplication by a
+ reciprocal. This can be significantly faster than an ordinary division
+ but can also have significantly less precision. Defaults to
+ ``fnoreciprocalmath``.
+
+.. _opt_funsafemathoptimizations:
+
+**f[no]unsafemathoptimizations**
+
+ Allow unsafe floatingpoint optimizations. Also implies:
+
+ * ``fassociativemath``
+ * ``freciprocalmath``
+ * ``fnosignedzeroes``
+ * ``fnotrappingmath``.
+
+ Defaults to ``fnounsafemathoptimizations``.
+
+.. _opt_ffinitemath:
+
+**f[no]finitemath**
+
+ Allow floatingpoint optimizations that assume arguments and results are
+ not NaNs or +Inf. This defines the ``__FINITE_MATH_ONLY__`` preprocessor macro.
+ Also implies:
+
+ * ``fnohonorinfinities``
+ * ``fnohonornans``
+
+ Defaults to ``fnofinitemath``.
+
.. _controllingcodegeneration:
Controlling Code Generation
@@ 1266,36 +1445,6 @@
This enables better devirtualization. Turned off by default, because it is
still experimental.
.. option:: ffastmath

 Enable fastmath mode. This defines the ``__FAST_MATH__`` preprocessor
 macro, and lets the compiler make aggressive, potentiallylossy assumptions
 about floatingpoint math. These include:

 * Floatingpoint math obeys regular algebraic rules for real numbers (e.g.
 ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
 ``(a + b) * c == a * c + b * c``),
 * operands to floatingpoint operations are not equal to ``NaN`` and
 ``Inf``, and
 * ``+0`` and ``0`` are interchangeable.

.. option:: fdenormalfpmath=[values]

 Select which denormal numbers the code is permitted to require.

 Valid values are: ``ieee``, ``preservesign``, and ``positivezero``,
 which correspond to IEEE 754 denormal numbers, the sign of a
 flushedtozero number is preserved in the sign of 0, denormals are
 flushed to positive zero, respectively.

.. option:: f[no]strictfloatcastoverflow

 When a floatingpoint value is not representable in a destination integer
 type, the code has undefined behavior according to the language standard.
 By default, Clang will not guarantee any particular result in that case.
 With the 'nostrict' option, Clang attempts to match the overflowing behavior
 of the target's native floattoint conversion instructions.

.. option:: fwholeprogramvtables
Enable wholeprogram vtable optimizations, such as singleimplementation
Event Timeline
Log In to Comment