Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set type of statement when processing
GlobalRef
s
Because we previously didn't set the type when processing `GlobalRef`, the optimizer was inserting unnecessary `PiNode`s. Before: ```julia julia> x::Int = 1 1 julia> function f() global x = 0 while x<10 x += 1 end x end f (generic function with 1 method) julia> @code_typed f() CodeInfo( 1 ── (Main.x = 0)::Any 2 ┄─ %2 = Main.x::Any │ %3 = (isa)(%2, Int64)::Bool └─── goto #4 if not %3 3 ── %5 = π (%2, Int64) │ %6 = Base.slt_int(%5, 10)::Bool └─── goto #5 4 ── %8 = (%2 < 10)::Bool └─── goto #5 5 ┄─ %10 = φ (#3 => %6, #4 => %8)::Bool └─── goto #10 if not %10 6 ── %12 = Main.x::Any │ %13 = (isa)(%12, Int64)::Bool └─── goto #8 if not %13 7 ── %15 = π (%12, Int64) │ %16 = Base.add_int(%15, 1)::Int64 └─── goto #9 8 ── %18 = (%12 + 1)::Int64 └─── goto #9 9 ┄─ %20 = φ (#7 => %16, #8 => %18)::Int64 │ (Main.x = %20)::Any └─── goto #2 10 ─ %23 = Main.x::Any └─── return %23 ) => Int64 ``` This PR: ```julia julia> @code_typed f() CodeInfo( 1 ─ (Main.x = 0)::Any 2 ┄ %2 = Main.x::Int64 │ %3 = Base.slt_int(%2, 10)::Bool └── goto #4 if not %3 3 ─ %5 = Main.x::Int64 │ %6 = Base.add_int(%5, 1)::Int64 │ (Main.x = %6)::Any └── goto #2 4 ─ %9 = Main.x::Int64 └── return %9 ) => Int64 ```
- Loading branch information