-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Inference regression (julia 0.5) on types-as-arguments #19096
Comments
Note that in v0.4, it inferred the wrong type for |
Another example: julia> VERSION
v"0.6.0-dev.1079"
julia> begin
pareval(h, x) = y -> h(x, y)
evalparevald(hx, y) = hx(y)
evalbypareval(h, x, y) = evalparevald(pareval(h, x), y)
end;
julia> @code_warntype evalbypareval((x,y) -> round(x,y), Int, 1.0)
Variables:
#self#::#evalbypareval
h::##3#4
x::Type{Int64}
y::Float64
#1::##1#2{##3#4,DataType}
Body:
begin
$(Expr(:inbounds, false))
# meta: location REPL[2] pareval 2
SSAValue(0) = h::##3#4
SSAValue(1) = x::Type{Int64}
# meta: pop location
$(Expr(:inbounds, :pop))
return (Main.round)(SSAValue(1),y::Float64)::Any
end::Any Workaround thanks to begin
pareval{T}(h, ::Type{T}) = y -> h(T, y)
evalparevald(hx, y) = hx(y)
evalbypareval{T}(h, ::Type{T}, y) = evalparevald(pareval(h, T), y)
end; Best! |
That's a somewhat different issue, and is basically a special case of wanting inference to do type/constant propagation across memory load/store operations. |
Sachas comment seems dup of #23471 |
julia 0.4 can handle a function definition like this:
even when one of the passed arguments is a type:
In contrast, with julia 0.5:
even though
rand
itself is perfectly fine:This was the subject of multiple PRs during the final days of 0.5 development (e.g., #17794, #18107), but perhaps we failed to notice the more systematic source, that this wasn't something we had to worry about in julia 0.4.
Also, this solves a mystery: since BaseBenchmark's
samerand
function uses this exact construction, this is almost surely the source of the massive performance regressions seen on the SIMD benchmarks with julia 0.5. (#16128 (comment)).The text was updated successfully, but these errors were encountered: