Ok, that makes sense!
It seems like collect(a)
should be preferred over [a;]
:
julia> @code_lowered [5:7;]
CodeInfo(
911 1 ββ Core.NewvarNode(:(a)) β
β Core.NewvarNode(:(i)) β
β Core.NewvarNode(:(#temp#@_7)) β
β %4 = (Base.convert)(Base.Int, 0) β
β n = (Core.typeassert)(%4, Base.Int) β
912 β %6 = rs β
β #temp#@_4 = (Base.iterate)(%6) β
β %8 = #temp#@_4 === nothing β
β %9 = (Base.not_int)(%8) β
ββββ goto #4 if not %9 β
2 ββ %11 = #temp#@_4 β
β ra@_13 = (Core.getfield)(%11, 1) β
β %13 = (Core.getfield)(%11, 2) β
913 β %14 = n β
β %15 = (Base.length)(ra@_13) β
β %16 = %14 + %15 β
β %17 = (Base.convert)(Base.Int, %16) β
β n = (Core.typeassert)(%17, Base.Int) β
β #temp#@_4 = (Base.iterate)(%6, %13) β
β %20 = #temp#@_4 === nothing β
β %21 = (Base.not_int)(%20) β
ββββ goto #4 if not %21 β
3 ββ goto #2 β
915 4 ββ %24 = (Core.apply_type)(Base.Vector, $(Expr(:static_parameter, 1))) β
β a = (%24)(Base.undef, n) β
916 β i = 1 β
917 β %27 = rs β
β #temp#@_7 = (Base.iterate)(%27) β
β %29 = #temp#@_7 === nothing β
β %30 = (Base.not_int)(%29) β
ββββ goto #10 if not %30 β
5 ββ %32 = #temp#@_7 β
β ra@_9 = (Core.getfield)(%32, 1) β
β %34 = (Core.getfield)(%32, 2) β
β %35 = ra@_9 β
β #temp#@_8 = (Base.iterate)(%35) β
β %37 = #temp#@_8 === nothing β
β %38 = (Base.not_int)(%37) β
ββββ goto #8 if not %38 β
6 ββ %40 = ra@_9 β
β ra@_12 = %40 β
β %42 = #temp#@_8 β
β x = (Core.getfield)(%42, 1) β
β %44 = (Core.getfield)(%42, 2) β
918 β $(Expr(:inbounds, true)) β
β (Base.setindex!)(a, x, i) β
β val = x β
β $(Expr(:inbounds, :pop)) β
β val β
919 β i = i + 1 β
β #temp#@_8 = (Base.iterate)(%35, %44) β
β %52 = #temp#@_8 === nothing β
β %53 = (Base.not_int)(%52) β
ββββ goto #8 if not %53 β
7 ββ goto #6 β
8 ββ #temp#@_7 = (Base.iterate)(%27, %34) β
β %57 = #temp#@_7 === nothing β
β %58 = (Base.not_int)(%57) β
ββββ goto #10 if not %58 β
9 ββ goto #5 β
921 10 β return a β
)
julia> @code_lowered collect(5:7)
CodeInfo(
925 1 β %1 = (Base.vcat)(r) β
βββ return %1 β
)
Or not!
julia> @code_lowered vcat(5:7)
CodeInfo(
911 1 ββ Core.NewvarNode(:(a)) β
β Core.NewvarNode(:(i)) β
β Core.NewvarNode(:(#temp#@_7)) β
β %4 = (Base.convert)(Base.Int, 0) β
β n = (Core.typeassert)(%4, Base.Int) β
912 β %6 = rs β
β #temp#@_4 = (Base.iterate)(%6) β
β %8 = #temp#@_4 === nothing β
β %9 = (Base.not_int)(%8) β
ββββ goto #4 if not %9 β
2 ββ %11 = #temp#@_4 β
β ra@_13 = (Core.getfield)(%11, 1) β
β %13 = (Core.getfield)(%11, 2) β
913 β %14 = n β
β %15 = (Base.length)(ra@_13) β
β %16 = %14 + %15 β
β %17 = (Base.convert)(Base.Int, %16) β
β n = (Core.typeassert)(%17, Base.Int) β
β #temp#@_4 = (Base.iterate)(%6, %13) β
β %20 = #temp#@_4 === nothing β
β %21 = (Base.not_int)(%20) β
ββββ goto #4 if not %21 β
3 ββ goto #2 β
915 4 ββ %24 = (Core.apply_type)(Base.Vector, $(Expr(:static_parameter, 1))) β
β a = (%24)(Base.undef, n) β
916 β i = 1 β
917 β %27 = rs β
β #temp#@_7 = (Base.iterate)(%27) β
β %29 = #temp#@_7 === nothing β
β %30 = (Base.not_int)(%29) β
ββββ goto #10 if not %30 β
5 ββ %32 = #temp#@_7 β
β ra@_9 = (Core.getfield)(%32, 1) β
β %34 = (Core.getfield)(%32, 2) β
β %35 = ra@_9 β
β #temp#@_8 = (Base.iterate)(%35) β
β %37 = #temp#@_8 === nothing β
β %38 = (Base.not_int)(%37) β
ββββ goto #8 if not %38 β
6 ββ %40 = ra@_9 β
β ra@_12 = %40 β
β %42 = #temp#@_8 β
β x = (Core.getfield)(%42, 1) β
β %44 = (Core.getfield)(%42, 2) β
918 β $(Expr(:inbounds, true)) β
β (Base.setindex!)(a, x, i) β
β val = x β
β $(Expr(:inbounds, :pop)) β
β val β
919 β i = i + 1 β
β #temp#@_8 = (Base.iterate)(%35, %44) β
β %52 = #temp#@_8 === nothing β
β %53 = (Base.not_int)(%52) β
ββββ goto #8 if not %53 β
7 ββ goto #6 β
8 ββ #temp#@_7 = (Base.iterate)(%27, %34) β
β %57 = #temp#@_7 === nothing β
β %58 = (Base.not_int)(%57) β
ββββ goto #10 if not %58 β
9 ββ goto #5 β
921 10 β return a β
)