Closed
Description
openedon Nov 8, 2014
Related to #2741, raising to negative integer power does not seem to use the LLVM powi
intrinsic and is much slower. This is somewhat unexpected (at least for me it was).
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.0-dev+1443 (2014-11-07 15:03 UTC)
_/ |\__'_|_|_|\__'_| | Commit 0790c92* (0 days old master)
|__/ | x86_64-apple-darwin14.0.0
julia> f(x) = x^-2
f (generic function with 1 method)
julia> g(x) = 1/x^2
g (generic function with 1 method)
julia> h(x) = 1/x/x
h (generic function with 1 method)
julia> f(1.) == g(1.) == h(1.)
true
julia> code_llvm(f, (Float64,))
define double @"julia_f;40365"(double) {
top:
%1 = call double @pow(double %0, double -2.000000e+00), !dbg !286
ret double %1, !dbg !286
}
julia> code_llvm(g, (Float64,))
define double @"julia_g;40366"(double) {
top:
%1 = fmul double %0, %0, !dbg !289
%2 = fdiv double 1.000000e+00, %1, !dbg !289
ret double %2, !dbg !289
}
julia> code_llvm(h, (Float64,))
define double @"julia_h;40367"(double) {
top:
%1 = fdiv double 1.000000e+00, %0, !dbg !292
%2 = fdiv double %1, %0, !dbg !292
ret double %2, !dbg !292
}
julia>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment