summaryrefslogtreecommitdiffstats
path: root/llvm/docs/LangRef.rst
diff options
context:
space:
mode:
authorJohn Regehr <regehr@cs.utah.edu>2016-05-12 20:55:09 +0000
committerJohn Regehr <regehr@cs.utah.edu>2016-05-12 20:55:09 +0000
commit6a493f2c4ae4064e488a23f020da826ddd553b13 (patch)
treee1589159360c1a9ee0d337d31849eadac4f05ff5 /llvm/docs/LangRef.rst
parent3525da74661cfbbf78b69b7b5628d7b6603d7927 (diff)
downloadbcm5719-llvm-6a493f2c4ae4064e488a23f020da826ddd553b13.tar.gz
bcm5719-llvm-6a493f2c4ae4064e488a23f020da826ddd553b13.zip
[Docs] clarify semantics of x.with.overflow intrinsics
Differential Revision: http://reviews.llvm.org/D20151 llvm-svn: 269346
Diffstat (limited to 'llvm/docs/LangRef.rst')
-rw-r--r--llvm/docs/LangRef.rst21
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2fa6293744f..a9b79ec502e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -10858,7 +10858,26 @@ then the result is the size in bits of the type of ``src`` if
Arithmetic with Overflow Intrinsics
-----------------------------------
-LLVM provides intrinsics for some arithmetic with overflow operations.
+LLVM provides intrinsics for fast arithmetic overflow checking.
+
+Each of these intrinsics returns a two-element struct. The first
+element of this struct contains the result of the corresponding
+arithmetic operation modulo 2\ :sup:`n`\ , where n is the bit width of
+the result. Therefore, for example, the first element of the struct
+returned by ``llvm.sadd.with.overflow.i32`` is always the same as the
+result of a 32-bit ``add`` instruction with the same operands, where
+the ``add`` is *not* modified by an ``nsw`` or ``nuw`` flag.
+
+The second element of the result is an ``i1`` that is 1 if the
+arithmetic operation overflowed and 0 otherwise. An operation
+overflows if, for any values of its operands ``A`` and ``B`` and for
+any ``N`` larger than the operands' width, ``ext(A op B) to iN`` is
+not equal to ``(ext(A) to iN) op (ext(B) to iN)`` where ``ext`` is
+``sext`` for signed overflow and ``zext`` for unsigned overflow, and
+``op`` is the underlying arithmetic operation.
+
+The behavior of these intrinsics is well-defined for all argument
+values.
'``llvm.sadd.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OpenPOWER on IntegriCloud