julia> function jl_foo()
x = 0
for i in 1:1000_000_000
x += 1
end
return x
end
jl_foo (generic function with 1 method)
julia> @code_native jl_foo()
.section __TEXT,__text,regular,pure_instructions
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movabsq $5868546160, %rcx ## imm = 0x15DCAE870
movq (%rcx), %rcx
cmpq $0, %rcx
je L28
movq %rcx, %rax
L28:
popq %rbp
retq
I would have expected the native code to be simply:
movabsq $1000000000, %rax
retq
Does anybody have an explanation for why it is loading the constant value from memory, and needlessly checking to see if it is 0 (where it leaves the value of 0 in %rax) before copying it into %rax?
Thanks, Scott