Skip to content

Commit

Permalink
More clearly describe the Conditional lattice element (#25550)
Browse files Browse the repository at this point in the history
As the resident compiler-dummy, I had trouble parsing the explanation.
After consulting the oracle at delphi^H^H^H^H^H^H Jameson and decyphering
its musings, I came up with this explanation, which I find simpler. I hope others
will too.
  • Loading branch information
Keno committed Jan 14, 2018
1 parent d569a29 commit 9924f79
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,20 @@ struct Const
Const(@nospecialize(v), a::Bool) = new(v, a)
end

# The type of a value might be Bool,
# but where the value of the boolean can be used in back-propagation to
# limit the type of some other variable
# The Conditional type tracks the set of branches on variable type info
# that was used to create the boolean condition
# The type of this value might be Bool.
# However, to enable a limited amount of back-propagagation,
# we also keep some information about how this Bool value was created.
# In particular, if you branch on this value, then may assume that in
# the true branch, the type of `var` will be limited by `vtype` and in
# the false branch, it will be limited by `elsetype`. Example:
# ```
# cond = isa(x::Union{Int, Float}, Int)::Conditional(x, Int, Float)
# if cond
# # May assume x is `Int` now
# else
# # May assume x is `Float` now
# end
# ```
mutable struct Conditional
var::Union{Slot,SSAValue}
vtype
Expand Down

0 comments on commit 9924f79

Please sign in to comment.