Displaying 20 results from an estimated 4000 matches similar to: "Semantics of fdiv division by zero"
2018 Sep 25
2
Unsafe floating point operation (FDiv & FRem) in LoopVectorizer
Hi,
Consider the following test case:
int foo(float *A, float *B, float *C, int len, int VSMALL) {
for (int i = 0; i < len; i++)
if (C[i] > VSMALL)
A[i] = B[i] / C[i];
}
In this test the div operation is conditional but llvm is generating unconditional div for this case:
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [
2007 Mar 22
3
[LLVMdev] a question about constant fold for fdiv
Hello, I have a question about the constant folding for fdiv instructions.
For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I
think this should be nan. Can anyone tell me why it is not nan?
Thanks.
Leo
_________________________________________________________________
Exercise your brain! Try Flexicon.
2007 Mar 22
2
[LLVMdev] a question about constant fold for fdiv
Reid Spencer wrote:
> On Thu, 2007-03-22 at 15:50 -0700, leo han wrote:
>
>> Hello, I have a question about the constant folding for fdiv instructions.
>> For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I
>> think this should be nan. Can anyone tell me why it is not nan?
>>
>
> I think the specification says that it is
2007 Mar 22
0
[LLVMdev] a question about constant fold for fdiv
On Thu, 2007-03-22 at 15:50 -0700, leo han wrote:
> Hello, I have a question about the constant folding for fdiv instructions.
> For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I
> think this should be nan. Can anyone tell me why it is not nan?
I think the specification says that it is "undefined" so any value will
do. inf is just as undefined
2007 Mar 22
0
[LLVMdev] a question about constant fold for fdiv
Jeff Cohen wrote:
> Reid Spencer wrote:
>> On Thu, 2007-03-22 at 15:50 -0700, leo han wrote:
>>
>>> Hello, I have a question about the constant folding for fdiv instructions.
>>> For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I
>>> think this should be nan. Can anyone tell me why it is not nan?
>>>
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
On 08.08.2013, at 18:25, Chad Rosier <chad.rosier at gmail.com> wrote:
> I would like to transform X/Y -> X*1/Y. Specifically, I would like to convert:
>
> define void @t1a(double %a, double %b, double %d) {
> entry:
> %div = fdiv fast double %a, %d
> %div1 = fdiv fast double %b, %d
> %call = tail call i32 @foo(double %div, double %div1)
> ret void
>
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
I did few transformation in Instruction *InstCombiner::visitFDiv() in an
attempt to remove some divs.
I may miss this case. If you need to implement this rule, it is better
done in Instcombine than in DAG combine.
Doing such xform early expose the redundancy of 1/y, which have positive
impact to neighboring code,
while DAG combine is bit blind.
You should be very careful, reciprocal is very
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
Hi Chad,
This is a great transform to do, but you’re right that it’s only safe under fast-math. This is particularly interesting when the original divisor is a constant so you can materialize the reciprocal at compile-time. You’re right that in either case, this optimization should only kick in when there is more than one divide instruction that will be changed to a mul.
I don’t have a strong
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
I believe we were under the impression that InstCombine, as a canonicalized/optimizer, should not increase code size but only reduce it.
Minor aside, but you don't need all of fast-math for the IR, just the "arcp" flag, which allows for replacement of division with reciprocal-multiply.
On Aug 8, 2013, at 10:21 AM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> I remember
2013 Aug 08
3
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
I remember why I didn't implement this rule in Instcombine. It add one
instruction. So,
this xform should be driven by a redundancy eliminator if you care code
size.
On 8/8/13 10:13 AM, Shuxin Yang wrote:
> I did few transformation in Instruction *InstCombiner::visitFDiv() in
> an attempt to remove some divs.
> I may miss this case. If you need to implement this rule, it is
>
2013 Aug 08
2
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
On Aug 8, 2013, at 9:56 AM, Jim Grosbach <grosbach at apple.com> wrote:
> Hi Chad,
>
> This is a great transform to do, but you’re right that it’s only safe under fast-math. This is particularly interesting when the original divisor is a constant so you can materialize the reciprocal at compile-time. You’re right that in either case, this optimization should only kick in when
2013 Aug 08
13
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
I would like to transform X/Y -> X*1/Y. Specifically, I would like to
convert:
define void @t1a(double %a, double %b, double %d) {
entry:
%div = fdiv fast double %a, %d
%div1 = fdiv fast double %b, %d
%call = tail call i32 @foo(double %div, double %div1)
ret void
}
to:
define void @t1b(double %a, double %b, double %d) {
entry:
%div = fdiv fast double 1.000000e+00, %d
%mul = fmul
2007 Mar 22
2
[LLVMdev] a question about constant fold for fdiv
Jeff Cohen wrote:
> Jeff Cohen wrote:
>> Reid Spencer wrote:
>>> On Thu, 2007-03-22 at 15:50 -0700, leo han wrote:
>>>
>>>> Hello, I have a question about the constant folding for fdiv instructions.
>>>> For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I
>>>> think this should be nan. Can anyone tell
2020 Feb 07
3
Why does FPBinOp(X, undef) -> NaN?
I came across this comment in SelectionDAG.cpp:
case ISD::FADD:
case ISD::FSUB:
case ISD::FMUL:
case ISD::FDIV:
case ISD::FREM:
// If both operands are undef, the result is undef. If 1 operand is undef,
// the result is NaN. This should match the behavior of the IR optimizer.
That isn't intuitive to me. I would have expected a binary FP
operation with one undef operand to
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
Seems incorrect but I forget the IEEE fp rules.
What if both x and y are infinity?
in that case x/y = NAN but you transformation will yield 0 as the result.
On 08/08/2013 09:25 AM, Chad Rosier wrote:
> I would like to transform X/Y -> X*1/Y. Specifically, I would like to
> convert:
>
> define void @t1a(double %a, double %b, double %d) {
> entry:
> %div = fdiv fast
2019 Aug 08
2
回复: [RFC] Improve iteration of estimating divisions
Hal,
Yes, speed is an important factor of making dicision. Here I just put the numerator into estimation, so it won't add any more instructions. A simple benchmark below keeps the same running time between the demo and current master:
```
float fdiv(unsigned int a, unsigned int b) {
return (float)a / (float)b;
}
float m;
__attribute__((noinline)) void foo() {
m = 0.0;
}
int main() {
2016 May 31
2
Signed Division and InstCombine
On 31 May 2016 at 15:42, Tim Northover <t.p.northover at gmail.com> wrote:
> A 16-bit division of INT16_MIN by -1 is undefined behaviour but the
> original ext/trunc version is well-defined as 0.
Sorry, INT16_MIN again actually. The main point still stands though, I think.
Tim.
2016 May 31
1
Signed Division and InstCombine
On 31 May 2016 at 16:02, Dilan Manatunga <manatunga at gmail.com> wrote:
> Just to verify, a 16-bit divion of INT16_MIN by -1 results in INT16_MIN
> again?
No, "sdiv i16 -32768, -1" is undefined behaviour. The version with an
"sext" and "trunc" avoids the undefined behaviour and does return
-32768.
> If the issue only occurs in this case, why
2013 Aug 08
0
[LLVMdev] Convert fdiv - X/Y -> X*1/Y
On Thu, Aug 8, 2013 at 1:56 PM, Mark Lacey <mark.lacey at apple.com> wrote:
>
> On Aug 8, 2013, at 9:56 AM, Jim Grosbach <grosbach at apple.com> wrote:
>
> Hi Chad,
>
> This is a great transform to do, but you’re right that it’s only safe
> under fast-math. This is particularly interesting when the original divisor
> is a constant so you can materialize the
2016 May 31
0
Signed Division and InstCombine
Just to verify, a 16-bit divion of INT16_MIN by -1 results in INT16_MIN
again?
If the issue only occurs in this case, why aren't there checks to see if we
can simplify sdiv in cases where we know that numerator is not INT16_MIN or
the denominator is not -1. For example, we could simplify divides involving
one operand constants. Is it because this case is most likely rare?
-Dilan
On Tue,