summaryrefslogtreecommitdiff
path: root/docs/LangRef.rst
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-03-09 15:27:48 +0000
committerSanjay Patel <spatel@rotateright.com>2018-03-09 15:27:48 +0000
commit8fca4625124a1fa570c3d677fe3b31f809e54df1 (patch)
treec511d6bf8cdd7c9b67476c0102b5d2f1b8c64106 /docs/LangRef.rst
parentbeee6ae8b954383340b48e73029cd8bc722e9554 (diff)
[LangRef] make it clear that FP instructions do not have side effects
Also, fix the undef vs. UB example to use 'sdiv' because that can trigger div-by-zero UB. The existing text for the constrained intrinsics says: "By default, LLVM optimization passes assume that the rounding mode is round-to-nearest and that floating point exceptions will not be monitored. Constrained FP intrinsics are used to support non-default rounding modes and accurately preserve exception behavior without compromising LLVM’s ability to optimize FP code when the default behavior is used." ...so the additional text with the normal FP opcodes should make the different modes clear. Differential Revision: https://reviews.llvm.org/D44216 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LangRef.rst')
-rw-r--r--docs/LangRef.rst25
1 files changed, 20 insertions, 5 deletions
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index 849c19c5aae..9d8242f29d7 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -3037,17 +3037,17 @@ uses with" concept would not hold.
.. code-block:: llvm
- %A = fdiv undef, %X
- %B = fdiv %X, undef
+ %A = sdiv undef, %X
+ %B = sdiv %X, undef
Safe:
- %A = undef
+ %A = 0
b: unreachable
These examples show the crucial difference between an *undefined value*
and *undefined behavior*. An undefined value (like '``undef``') is
allowed to have an arbitrary bit-pattern. This means that the ``%A``
-operation can be constant folded to '``undef``', because the '``undef``'
-could be an SNaN, and ``fdiv`` is not (currently) defined on SNaN's.
+operation can be constant folded to '``0``', because the '``undef``'
+could be zero, and zero divided by any value is zero.
However, in the second example, we can make a more aggressive
assumption: because the ``undef`` is allowed to be an arbitrary value,
we are allowed to assume that it could be zero. Since a divide by zero
@@ -6404,6 +6404,9 @@ Semantics:
""""""""""
The value produced is the floating-point sum of the two operands.
+This instruction is assumed to execute in the default floating-point
+environment. It has no side effects. Users can not assume that any
+floating-point exception state is updated by this instruction.
This instruction can also take any number of :ref:`fast-math
flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
@@ -6499,6 +6502,9 @@ Semantics:
""""""""""
The value produced is the floating-point difference of the two operands.
+This instruction is assumed to execute in the default floating-point
+environment. It has no side effects. Users can not assume that any
+floating-point exception state is updated by this instruction.
This instruction can also take any number of :ref:`fast-math
flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
@@ -6592,6 +6598,9 @@ Semantics:
""""""""""
The value produced is the floating-point product of the two operands.
+This instruction is assumed to execute in the default floating-point
+environment. It has no side effects. Users can not assume that any
+floating-point exception state is updated by this instruction.
This instruction can also take any number of :ref:`fast-math
flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
@@ -6724,6 +6733,9 @@ Semantics:
""""""""""
The value produced is the floating-point quotient of the two operands.
+This instruction is assumed to execute in the default floating-point
+environment. It has no side effects. Users can not assume that any
+floating-point exception state is updated by this instruction.
This instruction can also take any number of :ref:`fast-math
flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
@@ -6868,6 +6880,9 @@ The value produced is the floating-point remainder of the two operands.
This is the same output as a libm '``fmod``' function, but without any
possibility of setting ``errno``. The remainder has the same sign as the
dividend.
+This instruction is assumed to execute in the default floating-point
+environment. It has no side effects. Users can not assume that any
+floating-point exception state is updated by this instruction.
This instruction can also take any number of :ref:`fast-math
flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations: