Skip to content

Dead branch elimination after inlining #17880

@TotalVerb

Description

@TotalVerb

In the below min-repro, julia successfully inlines g(x);

g(x) = true
f(x) = g(x) ? 1 : 1.0

Nevertheless, 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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions