Skip to content

Conversation

JeffBezanson
Copy link
Member

Simpler alternative to #35904; just the type-widening part. With this we can still split ! as follows:

julia> g(x) = !x

julia> code_typed(g,(Any,))
1-element Array{Any,1}:
 CodeInfo(
1 ─ %1  = (isa)(x, Missing)::Bool
└──       goto #3 if not %1
2 ─       goto #6
3 ─ %4  = (isa)(x, Bool)::Bool
└──       goto #5 if not %4
4 ─ %6  = π (x, Bool)
│   %7  = Base.not_int(%6)::Bool
└──       goto #6
5 ─ %9  = !x::Any
└──       goto #6
6 ┄ %11 = φ (#2 => $(QuoteNode(missing)), #4 => %7, #5 => %9)::Any
└──       return %11
) => Any

Those branches are potentially helpful, and the !x::Any avoids adding the method table backedge, so we still get most of the latency improvement.

@JeffBezanson JeffBezanson added compiler:inference Type inference latency Latency labels Jun 8, 2020
@fingolfin
Copy link
Member

This fixes a type interference error we are experiencing in Julia 1.4 and 1.5 (see oscar-system/Oscar.jl#104). Any chance this could be backported to Julia 1.5?

@JeffBezanson
Copy link
Member Author

This isn't a bug fix --- it's probably just hiding the bug. But I'll see if the real cause can be fixed.

@fingolfin
Copy link
Member

OK, that makes sense (sorry, I didn't really look at the content of this PR, else I could have guessed).

Should I then open an issue for the inference problem we are seeing, and how to reproduce it?

@JeffBezanson
Copy link
Member Author

Yes, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference latency Latency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants