Try to clarify semantics of fptrunc

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 11:09:32 PDT 2015


On Wed, Sep 2, 2015 at 11:21 PM, Dan Liew <dan at su-root.co.uk> wrote:

> On 2 September 2015 at 15:11, Dan Gohman <sunfish at mozilla.com> wrote:
> > 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.
>
> This change makes it explicit that the rounding mode is not defined so
> I don't understand what you mean by the WebAssembly CodeGen being non
> conforming. The rounding mode can be anything, including any one of
> the five IEEE754 rounding modes.
>

LLVM's LangRef previously said that fptrunc always truncates. It doesn't,
on many common platforms, including WebAssembly. Your patch fixes that
problem.


> Although this is an improvement I think it would be better if fptrunc
> actually took an operand that specified the rounding mode. It would
> make static analysis easier, constant folding more correct and could
> be used by backends that support different rounding modes. This change
> would have a lot of impact though so I opted for the simpler change of
> just making the poorly defined behaviour of ``fptrunc`` more explicit.
>

I agree that such a change would have far broader implications. I'd expect
a change like this to be designed at the C/C++ language level first.

Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150903/b13f3be8/attachment.html>


More information about the llvm-commits mailing list