-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
performanceMust go fasterMust go faster
Description
It would be good to run some constant propagation before type inference runs for cases in which a type parameter is really constant, but we don't know because we compute with it before. E.g:
type foo{m}; end
inv{m}(x::foo{m}) = foo{-m}()
id{m}{x::foo{m}) = foo{m}()
For id, we get a nice
julia> code_typed(id,(foo{1},))
1-element Array{Any,1}:
:($(Expr(:lambda, {:x}, {{},{{:x,foo{1},0}},{}}, quote # /Users/kfischer/.julia/REPL/scripts/repl.jl, line 1:
return $(Expr(:new, foo{1}))::foo{1}
end)))
whereas for inv, we get
julia> code_typed(inv,(foo{1},))
1-element Array{Any,1}:
:($(Expr(:lambda, {:x}, {{},{{:x,foo{1},0}},{}}, quote # /Users/kfischer/.julia/REPL/scripts/repl.jl, line 1:
return top(apply_type)(foo,top(box)(Int64,top(neg_int)(1))::Int64)::Type{_<:foo{m}}()::foo{m}
end)))
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go faster