However, the machine code looks different in both cases:
julia> @code_native N_iterator(A, N)
.text
; β @ eachindex.jl:3 within `N_iterator'
pushq %rbp
movq %rsp, %rbp
; β @ eachindex.jl:4 within `N_iterator'
; ββ @ range.jl:5 within `Colon'
; βββ @ range.jl:280 within `UnitRange'
; ββββ @ range.jl:285 within `unitrange_last'
; βββββ @ operators.jl:350 within `>='
; ββββββ @ int.jl:441 within `<='
testq %rsi, %rsi
; ββββββ
jle L80
movq %rsi, %rax
sarq $63, %rax
andnq %rsi, %rax, %rcx
movq (%rdi), %r9
movq 8(%rdi), %rsi
; β @ eachindex.jl:5 within `N_iterator'
; ββ @ array.jl:847 within `setindex!'
leaq 1(%rsi), %r8
negq %rsi
negq %rcx
movl $1, %eax
nopl (%rax,%rax)
L48:
leaq (%rsi,%rax), %rdx
cmpq $1, %rdx
je L85
movq %rax, -8(%r9,%rax,8)
; ββ
; ββ @ range.jl:624 within `iterate'
; βββ @ promotion.jl:398 within `=='
leaq (%rcx,%rax), %rdx
addq $1, %rdx
; βββ
incq %rax
; βββ @ promotion.jl:398 within `=='
cmpq $1, %rdx
; βββ
jne L48
L80:
movq %rbp, %rsp
popq %rbp
retq
; ββ @ array.jl:847 within `setindex!'
L85:
movq %rsp, %rax
leaq -16(%rax), %rsi
movq %rsi, %rsp
movq %r8, -16(%rax)
movabsq $jl_bounds_error_ints, %rax
movl $1, %edx
callq *%rax
nopw %cs:(%rax,%rax)
nop
; ββ
julia> @code_native length_iterator(A)
.text
; β @ eachindex.jl:9 within `length_iterator'
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movq %rsi, -8(%rbp)
movq (%rsi), %rdi
; β @ eachindex.jl:10 within `length_iterator'
; ββ @ array.jl:219 within `length'
movq 8(%rdi), %rax
; ββ
; ββ @ range.jl:5 within `Colon'
; βββ @ range.jl:280 within `UnitRange'
; ββββ @ range.jl:285 within `unitrange_last'
; βββββ @ operators.jl:350 within `>='
; ββββββ @ int.jl:441 within `<='
testq %rax, %rax
; ββββββ
jle L96
movq %rax, %rcx
sarq $63, %rcx
andnq %rax, %rcx, %rdx
movq (%rdi), %r9
; β @ eachindex.jl:11 within `length_iterator'
; ββ @ array.jl:847 within `setindex!'
leaq 1(%rax), %r8
negq %rax
negq %rdx
movl $1, %ecx
nopw %cs:(%rax,%rax)
L64:
leaq (%rax,%rcx), %rsi
cmpq $1, %rsi
je L111
movq %rcx, -8(%r9,%rcx,8)
; ββ
; ββ @ range.jl:624 within `iterate'
; βββ @ promotion.jl:398 within `=='
leaq (%rdx,%rcx), %rsi
addq $1, %rsi
; βββ
incq %rcx
; βββ @ promotion.jl:398 within `=='
cmpq $1, %rsi
; βββ
jne L64
L96:
movabsq $jl_system_image_data, %rax
; β @ eachindex.jl:11 within `length_iterator'
movq %rbp, %rsp
popq %rbp
retq
; ββ @ array.jl:847 within `setindex!'
L111:
movq %rsp, %rax
leaq -16(%rax), %rsi
movq %rsi, %rsp
movq %r8, -16(%rax)
movabsq $jl_bounds_error_ints, %rax
movl $1, %edx
callq *%rax
; ββ