Skip to content

Commit

Permalink
Try to clarify the semantics of fptrunc
Browse files Browse the repository at this point in the history
* ``the value cannot fit within the destination type`` is ambiguous.
  It could mean overflow, underflow (not in the IEEE-754 sense) or a
  result that cannot be exactly represented and requires rounding or it
  could mean some combination of these. The semantics now state it means
  overflow **only**.

* Using "truncation" in the semantics is very misleading given that it
  doesn't necessarily truncate (i.e. round to zero). For example on
  x86_64 with SSE2 this is currently mapped to cvtsd2ss instruction
  who's rounding behaviour is dependent on the MXCSR register which
  is usually set to round to nearest even by default. The semantics
  now state that the rounding mode is undefined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246792 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
delcypher committed Sep 3, 2015
1 parent ad69a64 commit 9308aba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7524,10 +7524,12 @@ implies that ``fptrunc`` cannot be used to make a *no-op cast*.
Semantics:
""""""""""

The '``fptrunc``' instruction truncates a ``value`` from a larger
The '``fptrunc``' instruction casts a ``value`` from a larger
:ref:`floating point <t_floating>` type to a smaller :ref:`floating
point <t_floating>` type. If the value cannot fit within the
destination type, ``ty2``, then the results are undefined.
point <t_floating>` type. If the value cannot fit (i.e. overflows) within the
destination type, ``ty2``, then the results are undefined. If the cast produces
an inexact result, how rounding is performed (e.g. truncation, also known as
round to zero) is undefined.

Example:
""""""""
Expand Down

0 comments on commit 9308aba

Please sign in to comment.