The native code is short and looks identical. I can’t read assembly but whenever there’s type instability or extra allocations I expect way more lines. Last week I also ran into another example where 2 versions of a method had the same @code_native
but different @btime
. I’m on a Mac so anyone with a different machine should corroborate.
julia> foo(T,x) = exp(T(x))
foo (generic function with 1 method)
julia> foo(x) = exp(Float64(x))
foo (generic function with 2 methods)
julia> @code_native foo(Float64,10)
.section __TEXT,__text,regular,pure_instructions
; ┌ @ REPL[1]:1 within `foo`
subq $8, %rsp
; │┌ @ float.jl:146 within `Float64`
vcvtsi2sd %rdi, %xmm0, %xmm0
; │└
movabsq $exp, %rax
callq *%rax
popq %rax
retq
nopw (%rax,%rax)
; └
julia> @code_native foo(10)
.section __TEXT,__text,regular,pure_instructions
; ┌ @ REPL[2]:1 within `foo`
subq $8, %rsp
; │┌ @ float.jl:146 within `Float64`
vcvtsi2sd %rdi, %xmm0, %xmm0
; │└
movabsq $exp, %rax
callq *%rax
popq %rax
retq
nopw (%rax,%rax)
; └