Make uitofp and sitofp defined on overflow.
IEEE 754 defines the expected result on overflow. As far as I know,
hardware implementations (of f16), and compiler-rt (__floatuntisf)
correctly return +-Inf on overflow. And I can't think of any useful
transform that would take advantage of overflow being undefined here.
Differential Revision: https://reviews.llvm.org/D47807
llvm-svn: 334777
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 3d252e3..c95fca8 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -3288,14 +3288,12 @@
Convert an unsigned integer constant to the corresponding
floating-point constant. TYPE must be a scalar or vector floating-point
type. CST must be of scalar or vector integer type. Both CST and TYPE must
- be scalars, or vectors of the same number of elements. If the value
- won't fit in the floating-point type, the results are undefined.
+ be scalars, or vectors of the same number of elements.
``sitofp (CST to TYPE)``
Convert a signed integer constant to the corresponding floating-point
constant. TYPE must be a scalar or vector floating-point type.
CST must be of scalar or vector integer type. Both CST and TYPE must
- be scalars, or vectors of the same number of elements. If the value
- won't fit in the floating-point type, the results are undefined.
+ be scalars, or vectors of the same number of elements.
``ptrtoint (CST to TYPE)``
Perform the :ref:`ptrtoint operation <i_ptrtoint>` on constants.
``inttoptr (CST to TYPE)``
@@ -8851,8 +8849,9 @@
The '``uitofp``' instruction interprets its operand as an unsigned
integer quantity and converts it to the corresponding floating-point
-value. If the value cannot fit in the floating-point value, the results
-are undefined.
+value. If the value cannot be exactly represented, it is rounded using
+the default rounding mode.
+
Example:
""""""""
@@ -8891,9 +8890,9 @@
""""""""""
The '``sitofp``' instruction interprets its operand as a signed integer
-quantity and converts it to the corresponding floating-point value. If
-the value cannot fit in the floating-point value, the results are
-undefined.
+quantity and converts it to the corresponding floating-point value. If the
+value cannot be exactly represented, it is rounded using the default rounding
+mode.
Example:
""""""""