Try to clarify semantics of fptrunc

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 11:51:22 PDT 2015


Hi,

This patch follows on from an e-mail I sent to llvm-dev a while ago [1].

The issue I see is that the documented semantics of ``fptrunc`` are misleading

* ``the value cannot fit within the destination type`` is ambiguous.
  It could mean overflow or an inexact result that requires rounding or
  it could mean both.

* 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.

This patch tries to address this.


[1] http://lists.llvm.org/pipermail/llvm-dev/2015-August/089504.html

Thanks,
Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Try-to-clarify-the-semantics-of-fptrunc.patch
Type: text/x-patch
Size: 1662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150828/e42db8da/attachment.bin>


More information about the llvm-commits mailing list