[LLVMdev] Bug 16257 - fmul of undef ConstantExpr not folded to undef

Duncan Sands duncan.sands at deepbluecap.com
Mon Sep 1 03:04:24 PDT 2014


Hi Oleg,

On 01/09/14 15:42, Oleg Ranevskyy wrote:
> Hi,
>
> Thank you for your comment, Owen.
> My LLVM expertise is certainly not enough to make such decisions yet.
> Duncan, do you have any comments on this or do you know anyone else who can
> decide about preserving NaN payloads?

my take is that the first thing to do is to see what the IEEE standard says 
about NaNs.  Consider for example "fadd x, -0.0".  Does the standard specify the 
exact NaN bit pattern produced as output when a particular NaN x is input?  Or 
does it just say that the output is a NaN?  If the standard doesn't care exactly 
which NaN is output, I think it is reasonable for LLVM to assume it is whatever 
NaN is most convenient for LLVM; in this case that means using x itself as the 
output.

However this approach does implicitly mean that we may end up not folding 
floating point operations completely deterministically: depending on the 
optimization that kicks in, in one case we might fold to NaN A, and in some 
different optimization we might fold the same expression to NaN B.  I think this 
is pretty reasonable, but it is something to be aware of.

Ciao, Duncan.



More information about the llvm-dev mailing list