Skip to content

Commit

Permalink
more symbolism
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Nov 1, 2021
1 parent 8a89a1f commit 411fa5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
8 changes: 4 additions & 4 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ function from_interconditional(@nospecialize(typ), (; fargs, argtypes)::ArgInfo,
else
elsetype = tmeet(elsetype, widenconst(new_elsetype))
end
if (slot > 0 || condval !== false) && !(old vtype) # essentially vtype ⋤ old
if (slot > 0 || condval !== false) && vtype old
slot = id
elseif (slot > 0 || condval !== true) && !(old elsetype) # essentially elsetype ⋤ old
elseif (slot > 0 || condval !== true) && elsetype old
slot = id
else # reset: no new useful information for this slot
vtype = elsetype = Any
Expand Down Expand Up @@ -1606,7 +1606,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
at = widenconditional(abstract_eval_value(interp, e.args[i], vtypes, sv))
if !anyrefine
anyrefine = has_nontrivial_const_info(at) || # constant information
at fieldtype(t, i - 1) # just a type-level information, but more precise than the declared type
at fieldtype(t, i - 1) # just a type-level information, but more precise than the declared type
end
ats[i-1] = at
if at === Bottom
Expand Down Expand Up @@ -1809,7 +1809,7 @@ function widenreturn(@nospecialize(rt), @nospecialize(bestguess), nslots::Int, s
if !anyrefine
# TODO: consider adding && const_prop_profitable(a) here?
anyrefine = has_const_info(a) ||
a fieldtype(rt.typ, i)
a fieldtype(rt.typ, i)
end
fields[i] = a
end
Expand Down
24 changes: 22 additions & 2 deletions base/compiler/typelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ function maybe_extract_const_bool(c::AnyConditional)
end
maybe_extract_const_bool(@nospecialize c) = nothing

function (@nospecialize(a), @nospecialize(b))
"""
a ⊑ b -> Bool
The non-strict partial order over the type inference lattice.
"""
@nospecialize(a) @nospecialize(b) = begin
if isa(b, LimitedAccuracy)
if !isa(a, LimitedAccuracy)
return false
Expand Down Expand Up @@ -231,7 +236,22 @@ function ⊑(@nospecialize(a), @nospecialize(b))
return a === b
end
end
(@nospecialize(a), @nospecialize(b)) = !(b, a)

"""
a ⊏ b -> Bool
The strict partial order over the type inference lattice.
This is defined as the irreflexive kernel of `⊑`.
"""
@nospecialize(a) @nospecialize(b) = a b && !(b, a)

"""
a ⋤ b -> Bool
This order could be used as a slightly more efficient version of the strict order `⊏`,
where we can safely assume `a ⊑ b` holds.
"""
@nospecialize(a) @nospecialize(b) = !(b, a)

# Check if two lattice elements are partial order equivalent. This is basically
# `a ⊑ b && b ⊑ a` but with extra performance optimizations.
Expand Down

0 comments on commit 411fa5c

Please sign in to comment.