[llvm-dev] how to simplify FP ops with an undef operand?
Kaylor, Andrew via llvm-dev
llvm-dev at lists.llvm.org
Thu Mar 1 10:07:10 PST 2018
So you don’t think sNaNs can just be treated as if they were qNaNs? I understand why we would want to ignore the signaling part of things, but the rules for operating on NaNs are pretty clear and reasonable to implement. The signaling aspect can, I think, be safely ignored when we are in the mode of assuming the default FP environment.
As for the distinction between IEEE and LLVM IR, I would think we would want to define LLVM IR in such a way that it is possible to create and IEEE-compliant compiler. I know we’re not there yet, but we’re working toward it.
From: Chris Lattner [mailto:clattner at nondot.org]
Sent: Wednesday, February 28, 2018 8:42 PM
To: Friedman, Eli <efriedma at codeaurora.org>
Cc: Kaylor, Andrew <andrew.kaylor at intel.com>; Sanjay Patel <spatel at rotateright.com>; Matt Arsenault <arsenm2 at gmail.com>; llvm-dev <llvm-dev at lists.llvm.org>; John Regehr <regehr at cs.utah.edu>
Subject: Re: [llvm-dev] how to simplify FP ops with an undef operand?
On Feb 28, 2018, at 6:33 PM, Friedman, Eli <efriedma at codeaurora.org<mailto: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.
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180301/488b6191/attachment.html>
More information about the llvm-dev
mailing list