diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 9b7434c0a5a45..5ea1d761f1b26 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -1846,7 +1846,12 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState) end function conditional_changes(changes::VarTable, @nospecialize(typ), var::Slot) - if typ ⊑ (changes[slot_id(var)]::VarState).typ + oldtyp = (changes[slot_id(var)]::VarState).typ + # approximate test for `typ ∩ oldtyp` being better than `oldtyp` + # since we probably formed these types with `typesubstract`, the comparison is likely simple + if ignorelimited(typ) ⊑ ignorelimited(oldtyp) + # typ is better unlimited, but we may still need to compute the tmeet with the limit "causes" since we ignored those in the comparison + oldtyp isa LimitedAccuracy && (typ = tmerge(typ, LimitedAccuracy(Bottom, oldtyp.causes))) return StateUpdate(var, VarState(typ, false), changes, true) end return changes diff --git a/base/compiler/typelattice.jl b/base/compiler/typelattice.jl index 0f3dd7b4a84ed..a4064a7fa3ca6 100644 --- a/base/compiler/typelattice.jl +++ b/base/compiler/typelattice.jl @@ -91,7 +91,7 @@ struct StateUpdate end # Represent that the type estimate has been approximated, due to "causes" -# (only used in abstractinterpret, doesn't appear in optimize) +# (only used in abstract interpretion, doesn't appear in optimization) # N.B. in the lattice, this is epsilon smaller than `typ` (except Union{}) struct LimitedAccuracy typ