<div dir="ltr"><div>Clarifying that 'fptrunc' is not necessarily a truncation is indeed an improvement. It looks like WebAssembly CodeGen was previously nonconforming to LLVM's rules in that detail, because it's following the IEEE 754 semantics.<br></div><div><br></div>Dan<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 28, 2015 at 8:09 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>+destination type, ``ty2``, then the results are undefined. If the cast produces</div><div>+an inexact result how rounding is performed (e.g. truncation, also known as</div><div>+round to zero) is undefined.</div><div><br></div><div>probably want a comma between `result` and `how`</div><div><br></div><div>Other than that, this looks fine. I'd like a second opinion from Dan Gohman though since he has recently defined a target's floating point lowering.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 28, 2015 at 11:51 AM, Dan Liew <span dir="ltr"><<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
This patch follows on from an e-mail I sent to llvm-dev a while ago [1].<br>
<br>
The issue I see is that the documented semantics of ``fptrunc`` are misleading<br>
<br>
* ``the value cannot fit within the destination type`` is ambiguous.<br>
  It could mean overflow or an inexact result that requires rounding or<br>
  it could mean both.<br>
<br>
* Using "truncation" in the semantics is very misleading given that it<br>
  doesn't necessarily truncate (i.e. round to zero). For example on<br>
  x86_64 with SSE2 this is currently mapped to cvtsd2ss instruction<br>
  who's rounding behaviour is dependent on the MXCSR register which<br>
  is usually set to round to nearest even by default.<br>
<br>
This patch tries to address this.<br>
<br>
<br>
[1] <a href="http://lists.llvm.org/pipermail/llvm-dev/2015-August/089504.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2015-August/089504.html</a><br>
<br>
Thanks,<br>
Dan<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>