Skip to content

Commit

Permalink
Merge pull request #18893 from JuliaLang/jb/infersplat
Browse files Browse the repository at this point in the history
fix #10880, better inference of splatting constant containers
  • Loading branch information
JeffBezanson authored Oct 13, 2016
2 parents 919a3f7 + 146da3a commit 4ba21aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,10 @@ function precise_container_types(args, types, vtypes::VarTable, sv)
if isa(tti, TypeConstructor)
tti = tti.body
end
if isa(ai, Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
if isa(ti, Const) && (isa(ti.val, SimpleVector) || isa(ti.val, Tuple))
result[i] = Any[ abstract_eval_constant(x) for x in ti.val ]
elseif isa(ai, Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
aa = ai.args
result[i] = Any[ (isa(aa[j],Expr) ? aa[j].typ : abstract_eval(aa[j],vtypes,sv)) for j=2:length(aa) ]
if _any(isvarargtype, result[i])
Expand Down Expand Up @@ -1008,7 +1010,7 @@ function abstract_apply(af::ANY, fargs, aargtypes::Vector{Any}, vtypes::VarTable
n = length(at)
if n-1 > MAX_TUPLETYPE_LEN
tail = foldl((a,b)->tmerge(a,unwrapva(b)), Bottom, at[MAX_TUPLETYPE_LEN+1:n])
at = vcat(at[1:MAX_TUPLETYPE_LEN], Any[Vararg{tail}])
at = vcat(at[1:MAX_TUPLETYPE_LEN], Any[Vararg{widenconst(tail)}])
end
return abstract_call(af, (), at, vtypes, sv)
end
Expand Down
6 changes: 6 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,9 @@ gpure(x::Irrational) = fpure(x)
@test @code_typed(gpure(π))[1].pure
@test gpure() == gpure() == gpure()
@test gpure(π) == gpure(π) == gpure(π)

# issue #10880
function cat10880(a, b)
Tuple{a.parameters..., b.parameters...}
end
@inferred cat10880(Tuple{Int8,Int16}, Tuple{Int32})

3 comments on commit 4ba21aa

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

@Sacha0
Copy link
Member

@Sacha0 Sacha0 commented on 4ba21aa Oct 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of those regressions look real?

Please sign in to comment.