Interesting.
If I do a
f(x...) = multinomial(x...)
@code_native f(1,2,3,4,5)
There’s a sequence:
movabs rbx, offset ijl_box_int64
lea rdx, [rbp - 112]
mov r12, rsi
mov rcx, qword ptr [rax - 8]
mov qword ptr [rbp - 112], 20
mov rax, qword ptr [rcx]
mov qword ptr [rbp - 56], rcx # 8-byte Spill
mov qword ptr [rbp - 104], rax
mov qword ptr [rcx], rdx
vzeroupper
call rbx
So it seems something is being boxed. It’s likely something with the Vararg.
Incidentally, I see the same boxing with:
@noinline f(x...) = (s = 0; for i in x; s += i; end; s)
g(x...) = f(x...)
@code_native g(1,2,3)
though I do not get any allocations with @btime g(1,2,3)
I get this odd thing:
julia> @code_typed g(1,2,3)
CodeInfo(
1 ─ %1 = Core.getfield(x, 1)::Int64
│ %2 = Core.getfield(x, 2)::Int64
│ %3 = Core.getfield(x, 3)::Int64
│ %4 = invoke Main.f(%1::Int64, %2::Vararg{Int64}, %3)::Int64
└── return %4
) => Int64
(v1.11.1)