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

inference: forward Conditional inter-procedurally #42529

Merged
merged 4 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
aviatesk and vtjnash committed Oct 21, 2021
commit 4ef88d2677c5c3b0a6795e231416705d613bf643
8 changes: 4 additions & 4 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1238,10 +1238,10 @@ function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgIn
# try constant propagation with manual inlinings of some of the heuristics
# since some checks within `abstract_call_method_with_const_args` seem a bit costly
const_prop_entry_heuristic(interp, result, sv) || return CallMeta(rt, InvokeCallInfo(match, nothing))
argtypes′ = argtypes[4:end]
pushfirst!(argtypes′, ft)
fargs′ = fargs[4:end]
pushfirst!(fargs′, fargs[1])
argtypes′ = argtypes[3:end]
argtypes′[1] = ft
fargs′ = fargs[3:end]
fargs′[1] = fargs[1]
arginfo = ArgInfo(fargs′, argtypes′)
const_prop_argument_heuristic(interp, arginfo, sv) || return CallMeta(rt, InvokeCallInfo(match, nothing))
# # typeintersect might have narrowed signature, but the accuracy gain doesn't seem worth the cost involved with the lattice comparisons
Expand Down
9 changes: 5 additions & 4 deletions base/compiler/inferenceresult.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ function matching_cache_argtypes(
condargs = Tuple{Int,Int}[]
end
# using union-split signature, we may be able to narrow down `Conditional` to `Const`
(; vtype, elsetype) = cnd
if tmeet(vtype, widenconst(argtypes[slotid])) === Bottom
vtype = tmeet(cnd.vtype, widenconst(argtypes[slotid]))
elsetype = tmeet(cnd.elsetype, widenconst(argtypes[slotid]))
if vtype === Bottom
given_argtypes[i] = Const(false)
# union-split should never find a more precise information about `fargs[slotid]` than `Conditional`,
# otherwise there should have been a bug around `Conditional` construction or maintainance
@assert tmeet(elsetype, widenconst(argtypes[slotid])) !== Bottom "invalid Conditional element"
elseif tmeet(elsetype, widenconst(argtypes[slotid])) === Bottom
@assert elsetype !== Bottom "invalid Conditional element"
elseif elsetype === Bottom
given_argtypes[i] = Const(true)
else
push!(condargs, (slotid, i))
Expand Down