[llvm] r219542 - Return undef on FP <-> Int conversions that overflow (PR21330).

Chandler Carruth chandlerc at google.com
Fri Oct 17 19:11:12 PDT 2014


On Fri, Oct 17, 2014 at 6:49 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Fri, Oct 17, 2014 at 5:17 PM, Quentin Colombet <qcolombet at apple.com>
> wrote:
>
>> Hi Sanjay,
>>
>> I do not think this change is correct.
>> I have attached a test case with (before.ll) and without (after.ll) that
>> change and the related C file (test.c).
>>
>
> signed short a = 8*8*8*548.54 - 3.14; // <-- the value of a is undef.
>
> This line has undefined behavior; both C and C++ are very clear about
> this. The transformation is correct at the language semantics level. And it
> appears correct at the IR level too, whether you interpret "the results are
> undefined" as meaning undefined behavior or (strictly weaker) an undef
> value.


I think it would be good to make the LangRef much more clear about this. I
think "produces an undef value" is more concrete?


> It would be correct to treat this as poison, not just as undef, from a
> language semantics perspective.


I don't think there is any utility in thinking about poison here.... undef
seems a good way to model this. I'm increasingly of the opinion we can all
the optimizations we would ever want from undef alone.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141017/ec211a69/attachment.html>


More information about the llvm-commits mailing list