Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad result for powi inside some immutable types #6506

Closed
JeffBezanson opened this issue Apr 11, 2014 · 11 comments
Closed

bad result for powi inside some immutable types #6506

JeffBezanson opened this issue Apr 11, 2014 · 11 comments
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently upstream The issue is with an upstream dependency, e.g. LLVM
Milestone

Comments

@JeffBezanson
Copy link
Member

julia> foo(n) = (1.0^n, 2.0^n, 3.0^n)
foo (generic function with 1 method)

julia> foo(2)
(9.0,9.0,NaN)
@JeffBezanson
Copy link
Member Author

See fa315c9#commitcomment-5987511

@Keno
Copy link
Member

Keno commented Apr 11, 2014

Ok, I'm fairly sure the issue is in the return from the function and it does seem like an llvm bug to me. Haven't yet been able to replicate it in lli though.

@vtjnash
Copy link
Member

vtjnash commented Apr 12, 2014

perhaps the llvm vectorizor expects power-of-two-length vectors?

@cmundi
Copy link
Contributor

cmundi commented Apr 12, 2014

f5(n) = (1.0^n, 2.0^n, 3.0^n, 4.0^n, 5.0^n)
f6(n) = (1.0^n, 2.0^n, 3.0^n, 4.0^n, 5.0^n, 6.0^n)
Both work as expected. The LLVM IR for f2, f3, f4, f5, f6 all look correct (casual inspection). Ihave not looked but I suspect a backend codegen optimization has gone amok for the special case of three return values. Just guessing.

@Keno
Copy link
Member

Keno commented Apr 23, 2014

Reported as http://llvm.org/bugs/show_bug.cgi?id=19530

@JeffBezanson
Copy link
Member Author

We will have to work around this. I propose recognizing small constants (2 and 3) in our powi_llvm intrinsic and converting them to multiplies, falling back on calling libm pow.

@JeffBezanson JeffBezanson added this to the 0.3 milestone May 3, 2014
@simonster simonster mentioned this issue May 26, 2014
@Keno
Copy link
Member

Keno commented Aug 19, 2014

I'm tracking down the upstream issue here. Looks to be in DAG legelization. Before:
dag1
After:
dag2

@Keno
Copy link
Member

Keno commented Aug 19, 2014

Upstream patch is at http://reviews.llvm.org/D4968.

@quinnj
Copy link
Member

quinnj commented Aug 19, 2014

What is that sorcery??

@Keno
Copy link
Member

Keno commented Aug 20, 2014

Committed as http://reviews.llvm.org/rL216117.

@staticfloat
Copy link
Member

No wonder Keno wanted GraphViz fixed. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently upstream The issue is with an upstream dependency, e.g. LLVM
Projects
None yet
Development

No branches or pull requests

6 participants