Skip to content

Commit

Permalink
inference: yet more fix for ifelse lattice (JuliaLang#39247)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jan 14, 2021
1 parent eb567b2 commit 5bb0659
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,13 @@ function abstract_call_builtin(interp::AbstractInterpreter, f::Builtin, fargs::U
cnd = argtypes[2]
if isa(cnd, Conditional)
newcnd = widenconditional(cnd)
tx = argtypes[3]
ty = argtypes[4]
if isa(newcnd, Const)
# if `cnd` is constant, we should just respect its constantness to keep inference accuracy
return newcnd.val ? tx : ty
return newcnd.val::Bool ? tx : ty
else
# try to simulate this as a real conditional (`cnd ? x : y`), so that the penalty for using `ifelse` instead isn't too high
tx = argtypes[3]
ty = argtypes[4]
a = ssa_def_slot(fargs[3], sv)
b = ssa_def_slot(fargs[4], sv)
if isa(a, Slot) && slot_id(cnd.var) == slot_id(a)
Expand Down

0 comments on commit 5bb0659

Please sign in to comment.