I donβt quite understand whatβs happening here, but this is the output:
@code_native c_cheating(1_000_000)
.text
; β @ In[1]:3 within `c_cheating'
; ββ @ In[1]:1 within `*'
pushq %rbx
; ββ
; ββ @ int.jl:87 within `*'
leaq (%rdi,%rdi), %rdx
; ββ
; β @ In[1]:4 within `c_cheating'
; ββ @ range.jl:22 within `Colon'
; βββ @ range.jl:24 within `_colon'
; ββββ @ range.jl:256 within `StepRange' @ range.jl:205
movabsq $steprange_last, %rax
movl $4, %ebx
movl $4, %edi
movl $4, %esi
callq *%rax
; ββββ
; ββ @ range.jl:620 within `iterate'
; βββ @ range.jl:501 within `isempty'
; ββββ @ bool.jl:40 within `&'
cmpq $4, %rax
; ββββ
jl L71
; β @ In[1]:5 within `c_cheating'
negq %rax
xorl %ecx, %ecx
nopl (%rax,%rax)
; ββ @ int.jl:86 within `+'
L48:
addq %rbx, %rcx
; ββ
; ββ @ range.jl:624 within `iterate'
; βββ @ promotion.jl:398 within `=='
leaq (%rax,%rbx), %rdx
addq $4, %rdx
; βββ
addq $4, %rbx
; βββ @ promotion.jl:398 within `=='
cmpq $4, %rdx
; βββ
jne L48
jmp L73
L71:
xorl %ecx, %ecx
; β @ In[1]:7 within `c_cheating'
L73:
movq %rcx, %rax
popq %rbx
retq
nop
; β
@code_native sum(4:4:(1_000_000*2))
.text
; β @ range.jl:1022 within `sum'
pushq %rbx
movq %rdi, %rbx
; β @ range.jl:1023 within `sum'
movabsq $length, %rax
callq *%rax
movq (%rbx), %rcx
; β @ range.jl:1025 within `sum'
; ββ @ int.jl:87 within `*'
imulq %rax, %rcx
; ββ
; ββ @ int.jl:85 within `-'
leaq -1(%rax), %rdx
; ββ
testb $1, %al
jne L45
; ββ @ int.jl:461 within `>>' @ int.jl:454
sarq %rax
; ββ
; ββ @ int.jl:87 within `*'
imulq %rdx, %rax
imulq 8(%rbx), %rax
; ββ
jmp L60
; ββ @ int.jl:461 within `>>' @ int.jl:454
L45:
sarq %rdx
; ββ
; ββ @ int.jl:87 within `*'
imulq %rax, %rdx
imulq 8(%rbx), %rdx
movq %rdx, %rax
; ββ
; ββ @ int.jl:86 within `+'
L60:
addq %rcx, %rax
; ββ
popq %rbx
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)
; β
And for
@code_native c_loop(1_000_000)
is just too big to place here.