Skip to content

Commit

Permalink
Further tweaks to LimitedAccuracy lattice operations (#48126)
Browse files Browse the repository at this point in the history
As discussed in #48045:
1. Switch the order of `causes` inclusion to make wider
   elements have fewer causes.
2. Fix two typos
3. Restore property that equal ulimited types will be
   preserved (though with potentially updated `causes` lists).
  • Loading branch information
Keno authored Jan 22, 2023
1 parent 2949879 commit 7630606
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/compiler/typelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function ⊑(lattice::InferenceLattice, @nospecialize(a), @nospecialize(b))

# a and b's unlimited types are equal.
isa(a, LimitedAccuracy) || return false # b is limited, so ε smaller
return a.causes b.causes
return b.causes a.causes
end

function (lattice::OptimizerLattice, @nospecialize(a), @nospecialize(b))
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ end

# Approximated types are lattice equal. Merge causes.
if suba && subb
causes = merge_causes(causesa, causesb)
issimplertype(lattice, typeb, typea) && return LimitedAccuracy(typeb, causesb)
return LimitedAccuracy(typeb, merge_causes(causesa, causesb))
elseif suba
issimplertype(lattice, typeb, typea) && return LimitedAccuracy(typeb, causesb)
causes = causesb
Expand Down Expand Up @@ -453,6 +452,7 @@ end
subb = (lattice, typeb, typea)
end

suba && subb && return LimitedAccuracy(typea, causes)
subb && issimplertype(lattice, typea, typeb) && return LimitedAccuracy(typea, causes)
return LimitedAccuracy(tmerge(widenlattice(lattice), typea, typeb), causes)
end
Expand Down

0 comments on commit 7630606

Please sign in to comment.