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

Duncan Sands duncan.sands at deepbluecap.com
Thu Aug 28 07:58:14 PDT 2014


Hi Stephen,

>> In the case of fadd, given that "fadd x, -0.0" is always equal to x (same bit pattern), then "fadd x, undef" can be folded to "x" (currently it is folded to undef, which is wrong).  This implies that it is correct to fold "fadd undef, undef" to undef.  Actually is it true that "fadd x, -0.0" always has exactly the same bits as x, or does it just compare equal to x when doing floating point comparisons?
>
> fadd x, –0.0 always has the same bit pattern as x, unless:
>
> 	(a) x is a signaling NaN on a platform that supports them.

because you get a trap?

> 	(b) x is a quiet NaN on a platform that does not propagate NaN payloads (e.g. ARM with "default nan" bit set in fpscr).

What do you get in this case?

> 	(c) x is +0.0 and the rounding mode is round down.

So far rounding modes were always ignored in LLVM AFAIK.

Note that LLVM folds "fadd x, -0.0" to x (in InstructionSimplify), which made me 
think of exploiting this for the undef case.

Ciao, Duncan.




More information about the llvm-dev mailing list