fptrunc undef results

Currently opt simplifies

define float @test() {
%Y = fptrunc double 1.0E+300 to float ; yields undefined
ret float %Y


define float @test() #0 {
ret float 0x7FF0000000000000

This is the result I would expect based on the IEEE754 specification, but the documentation http://llvm.org/docs/LangRef.html#fptrunc-to-instruction states that I should have expected an undef result.

I found these threads in the mailing list that look relevant:

I was unable to find any answers to the latter and in the first one the mismatch between the LLVM fptrunc definition and IEEE behaviour is pointed out, but not actually discussed.

Where can I look up for further information?

I tried to go through some of the code (specifically, I found the constant folding code this in APFloat.cpp:1972), but I was unable to find any way in which it could generate an undef value.

Is the documentation misleading or is this a missed optimization?


PS: Apologies if you get this e-mail twice