Skip to content
Merged
Changes from all commits
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
28 changes: 19 additions & 9 deletions Compiler/src/typelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
# inside the global code cache.
import Core: Const, InterConditional, PartialStruct

function may_form_limited_typ(@nospecialize(aty), @nospecialize(bty), @nospecialize(xty))
if aty isa LimitedAccuracy
if bty isa LimitedAccuracy
return LimitedAccuracy(xty, union!(copy(aty.causes), bty.causes))
Copy link
Member

Choose a reason for hiding this comment

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

Lgtm. As a followup improvement, note that this actually should be intersect for more accuracy, which we could implement by changing causes to a number (the frame/cycle id) and use min/max on that

else
return LimitedAccuracy(xty, copy(aty.causes))
end
elseif bty isa LimitedAccuracy
return LimitedAccuracy(xty, copy(bty.causes))
end
return nothing
end

"""
cnd::Conditional

Expand Down Expand Up @@ -40,9 +53,8 @@ struct Conditional
isdefined::Bool=false)
assert_nested_slotwrapper(thentype)
assert_nested_slotwrapper(elsetype)
if thentype isa LimitedAccuracy || elsetype isa LimitedAccuracy
return Bool
end
limited = may_form_limited_typ(thentype, elsetype, Bool)
limited !== nothing && return limited
return new(slot, thentype, elsetype, isdefined)
end
end
Expand Down Expand Up @@ -86,9 +98,8 @@ struct MustAlias
assert_nested_slotwrapper(fldtyp)
# @assert !isalreadyconst(vartyp) "vartyp is already const"
# @assert !isalreadyconst(fldtyp) "fldtyp is already const"
if vartyp isa LimitedAccuracy || fldtyp isa LimitedAccuracy
return fldtyp
end
limited = may_form_limited_typ(vartyp, fldtyp, fldtyp)
limited !== nothing && return limited
return new(slot, vartyp, fldidx, fldtyp)
end
end
Expand All @@ -110,9 +121,8 @@ struct InterMustAlias
assert_nested_slotwrapper(fldtyp)
# @assert !isalreadyconst(vartyp) "vartyp is already const"
# @assert !isalreadyconst(fldtyp) "fldtyp is already const"
if vartyp isa LimitedAccuracy || fldtyp isa LimitedAccuracy
return fldtyp
end
limited = may_form_limited_typ(vartyp, fldtyp, fldtyp)
limited !== nothing && return limited
return new(slot, vartyp, fldidx, fldtyp)
end
end
Expand Down