Displaying 20 results from an estimated 5000 matches similar to: "Why does FPBinOp(X, undef) -> NaN?"
2020 Feb 07
2
Why does FPBinOp(X, undef) -> NaN?
On Fri, Feb 7, 2020 at 12:29 PM Nuno Lopes <nunoplopes at sapo.pt> wrote:
>
> It's not correct (output of Alive2):
>
> define half @fn(half %a) {
> %b = fadd half %a, undef
> ret half %b
> }
> =>
> define half @fn(half %a) {
> ret half undef
> }
> Transformation doesn't verify!
> ERROR: Value mismatch
>
> Example:
> half %a
2018 Feb 28
3
how to simplify FP ops with an undef operand?
%y = fadd float %x, undef
Can we simplify this?
Currently in IR, we do nothing for fadd/fsub/fmul. For fdiv/frem, we
propagate undef. The code comment for fdiv/frem says:
"the undef could be a snan"
If that's correct, then shouldn't it be the same for fadd/fsub/fmul? But
this can't be correct because we support targets that don't raise
exceptions...and even targets
2018 Feb 28
0
how to simplify FP ops with an undef operand?
I’m not sure the transformation happening with fdiv is correct. If we have “%y = fdiv float %x, undef” and %x is a NaN then the result will be NaN for any value of the undef, right? So if I understand the undef rules correctly (never a certainty) then we can’t safely replace the expression with undef. We could, I think, replace it with “%y = %x” though. I think the same is true for fadd, fsub,
2014 Aug 07
3
[LLVMdev] Proposal: Add a target lowering hook to state that target supports floating point exception behavior.
Hello All,
the patch below adds a target lowering hook to state that the target supports (or not) floating point exception behavior. The patch is small and contains one possible use for the hook (folding potentially exception raising fp operations).
Any comments?
Thanks
Pedro
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: opensource1.txt
2018 Feb 28
2
how to simplify FP ops with an undef operand?
Yes, if %x is a NaN, we should expect that NaN is propagated.
I'm still not sure what to do here. We can take comfort in knowing that
whatever we do is likely an improvement over the current situation though.
:)
That's because the code in InstSimplify is inconsistent with the LangRef:
http://llvm.org/docs/LangRef.html#undefined-values (UB for fdiv by 0?)
...and both of those are
2018 Feb 28
0
how to simplify FP ops with an undef operand?
Why is NaN “just ‘undef’ in IR”? NaN is a specific value with well-defined behavior. I would think that unless the no-NaNs flag is used we need to preserve the behavior of NaNs.
From: Sanjay Patel [mailto:spatel at rotateright.com]
Sent: Wednesday, February 28, 2018 12:08 PM
To: Kaylor, Andrew <andrew.kaylor at intel.com>
Cc: llvm-dev <llvm-dev at lists.llvm.org>; Nuno Lopes
2014 Aug 08
3
[LLVMdev] Proposal: Add a target lowering hook to state that target supports floating point exception behavior.
I assume you meant to ask for ports that *don’t* support floating point exceptions. To my knowledge, neither R600 nor NVPTX support floating point exceptions.
—Owen
> On Aug 8, 2014, at 2:41 PM, Eric Christopher <echristo at gmail.com> wrote:
>
> There's a lot of cut and paste in those routines. Can you do something
> to unify it a bit? Also, do we have any ports that
2018 Feb 28
2
how to simplify FP ops with an undef operand?
Correct - NaN is not undef in IR. But we don't have a NaN in this example.
We have its moral equivalent in LLVM - an uninitialized value, undef.
So we're not introducing any extra uncertainty by propagating the undef.
The backend can choose whatever encoding of undef makes sense when lowering?
And yes, I don't know why FP-div-by-zero would ever be UB. I think that
text in the LangRef
2018 Feb 28
0
how to simplify FP ops with an undef operand?
What I’m saying is that if we have one operand that is not an undef value then that operand might be NaN and if it is then the result must be NaN. So while it may be true that we don’t have a NaN, it is not true that we definitely do not have a NaN in the example. This is analogous to the example in the language reference where it says “%A = or %X, undef” -> “%A = undef” is unsafe because any
2018 Feb 28
3
how to simplify FP ops with an undef operand?
Ah, thanks for explaining. So given that any of these ops will return NaN
with a NaN operand, let's choose the undef operand value to be NaN. That
means we can fold all of these to a NaN constant in the general case.
But if we have 'nnan' FMF, then we can fold harder to undef?
nnan - Allow optimizations to assume the arguments and result are not NaN.
Such optimizations are required to
2018 Feb 28
0
how to simplify FP ops with an undef operand?
I'm pretty sure that isn't what nnan is supposed to mean. If the result
of nnan math were undefined in the sense of "undef", programs using nnan
could have undefined behavior if the result is used in certain ways
which would not be undefined for any actual float value (e.g. converting
the result to a string), which seems like a surprising result. And I
don't think we
2018 Mar 02
0
how to simplify FP ops with an undef operand?
On Mar 1, 2018, at 10:07 AM, Kaylor, Andrew <andrew.kaylor at intel.com> wrote:
> 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
2009 May 20
2
[LLVMdev] [PATCH] Add new phase to legalization to handle vector operations
Per subject, this patch adding an additional pass to handle vector
operations; the idea is that this allows removing the code from
LegalizeDAG that handles illegal types, which should be a significant
simplification. There are still some issues with this patch, but does
the approach look sane?
-Eli
-------------- next part --------------
Index: lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
2018 Mar 01
0
how to simplify FP ops with an undef operand?
We can do "add %x, undef" => "undef" because for any value of %x, we can
always find a value that when added to %x produces any value in the domain
of integers.
This is not the case with floats since with some inputs, e.g., NaNs, we are
not able to produce some values in the domain (e.g., there's no value of %x
that makes "fadd NaN, %x" return 42.0).
In
2018 Mar 01
6
how to simplify FP ops with an undef operand?
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
2018 Feb 28
5
how to simplify FP ops with an undef operand?
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.” For the second part, which the nnan FMF is present, I’m not sure. The particulars of the semantics of nnan are unclear to me.
But let me explore what Eli is saying. It sounds reasonable, but I have a question about it.
Suppose we have the nnan FMF set, and we encounter
2018 Mar 01
2
how to simplify FP ops with an undef operand?
On Thu, Mar 1, 2018 at 2:08 AM, Nuno Lopes <nunoplopes at sapo.pt> wrote:
> We can do "add %x, undef" => "undef" because for any value of %x, we can
> always find a value that when added to %x produces any value in the domain
> of integers.
>
> This is not the case with floats since with some inputs, e.g., NaNs, we
> are not able to produce some
2019 Feb 25
4
funnel shift, select, and poison
There's a question about the behavior of funnel shift [1] + select and
poison here that reminds me of previous discussions about select and poison
[2]:
https://github.com/AliveToolkit/alive2/pull/32#discussion_r257528880
Example:
define i8 @fshl_zero_shift_guard(i8 %x, i8 %y, i8 %sh) {
%c = icmp eq i8 %sh, 0
%f = fshl i8 %x, i8 %y, i8 %sh
%s = select i1 %c, i8 %x, i8 %f ; shift amount is 0
2014 Sep 19
2
[LLVMdev] More careful treatment of floating point exceptions
Hi Sanjay,
Thanks, I saw this flag and it's definitely should be considered, but
it appeared to me to be static characteristic of target platform. I'm
not sure how appropriate it would be to change its value from a front-end.
It says "Has", while optional flag would rather say "Uses" meaning that
implementation cares about floating point exceptions.
Regards,
Sergey
2009 May 21
0
[LLVMdev] [PATCH] Add new phase to legalization to handle vector operations
On Wed, May 20, 2009 at 4:55 PM, Dan Gohman <gohman at apple.com> wrote:
> Can you explain why you chose the approach of using a new pass?
> I pictured removing LegalizeDAG's type legalization code would
> mostly consist of finding all the places that use TLI.getTypeAction
> and just deleting code for handling its Expand and Promote. Are you
> anticipating something more