[llvm-dev] how to simplify FP ops with an undef operand?

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 28 20:41:42 PST 2018

> On Feb 28, 2018, at 6:33 PM, Friedman, Eli <efriedma at codeaurora.org> wrote:
> On 2/28/2018 5:46 PM, Chris Lattner wrote:
>> On Feb 28, 2018, at 3:29 PM, Kaylor, Andrew via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>>> For the first part of Sanjay’s question, I think the answer is, “Yes, we can fold all of these to NaN in the general case.”
>> Agreed.  Those IR instructions are undefined on SNAN, and that undef could take on an SNAN value.  Folding these instructions to undef seems reasonable, and it is arguable that you could even fold it to an ‘unreachable'.
> fdiv snan, snan is undefined?  As opposed to producing a qnan, as specified by IEEE-754?

You’re talking about IEEE, I’m talking about LLVM IR.  LLVM IR is undefined on SNaNs.  It looks like LangRef isn’t clear about this, the only mention of SNaNs is in this statement:

	"fdiv is not (currently) defined on SNaN’s.”

However, fdiv/fmul/etc are pervasively treated as not having side effects.  The intention, and the only sensible definition for them, is that they are undefined on SNaNs.  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180228/1125e00c/attachment.html>

More information about the llvm-dev mailing list