-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
Description
In the below min-repro, julia successfully inlines g(x);
g(x) = true
f(x) = g(x) ? 1 : 1.0Nevertheless, inference does not eliminate the dead branch, and so the result is boxed:
julia> @code_warntype f(1)
Variables:
#self#::#f
x::Int64
Body:
begin
unless $(QuoteNode(true)) goto 3
return 1
3:
return 1.0
end::Union{Float64,Int64}Although LLVM successfully removes the branch, it is too late to unbox the return value.
Would it be feasible to run dead branch elimination after inlining?
(Related to this SO question: http://stackoverflow.com/questions/38811881/possible-to-constant-propagate-if-statement-without-dispatch)