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

improve optimization passes to produce more compact IR #20853

Merged
merged 6 commits into from
Mar 10, 2017
Next Next commit
improve ability to inline away typeassert and ===
this was affected by using `Const` in more cases instead of `Type{}`
  • Loading branch information
JeffBezanson committed Mar 8, 2017
commit 3334f7fd54c31cf92dda2298e90f6db5da4bc3e7
10 changes: 5 additions & 5 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3467,8 +3467,7 @@ struct InvokeData
texpr
end

function inline_as_constant(val::ANY, argexprs, sv::InferenceState,
invoke_data::ANY)
function inline_as_constant(val::ANY, argexprs, sv::InferenceState, invoke_data::ANY)
if invoke_data === nothing
invoke_fexpr = nothing
invoke_texpr = nothing
Expand Down Expand Up @@ -3661,16 +3660,17 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference

if (f === typeassert || ft ⊑ typeof(typeassert)) && length(atypes)==3
# typeassert(x::S, T) => x, when S<:T
if isType(atypes[3]) && isleaftype(atypes[3]) &&
atypes[2] ⊑ atypes[3].parameters[1]
a3 = atypes[3]
if (isType(a3) && isleaftype(a3) && atypes[2] ⊑ a3.parameters[1]) ||
(isa(a3,Const) && isa(a3.val,Type) && atypes[2] ⊑ a3.val)
return (argexprs[2], ())
end
end
topmod = _topmod(sv)
# special-case inliners for known pure functions that compute types
if sv.params.inlining
if isa(e.typ, Const) # || isconstType(e.typ)
if (f === apply_type || f === fieldtype || f === typeof ||
if (f === apply_type || f === fieldtype || f === typeof || f === (===) ||
istopfunction(topmod, f, :typejoin) ||
istopfunction(topmod, f, :isbits) ||
istopfunction(topmod, f, :promote_type) ||
Expand Down