Skip to content

Instantly share code, notes, and snippets.

@bicycle1885
Created June 4, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bicycle1885/6f6725059614310b4f83df9fa3b56548 to your computer and use it in GitHub Desktop.
Save bicycle1885/6f6725059614310b4f83df9fa3b56548 to your computer and use it in GitHub Desktop.
Constant folding
const a = (1, 2, 3, 4)
function func(b)
sum = 0
for i in 1:4
sum += a[i] * b[i]
end
return sum
end
function main()
b = (5, 6, 7, 8)
println(func(b))
end
# julia> @code_llvm debuginfo=:none main()
#
# define nonnull %jl_value_t addrspace(10)* @japi1_main_12289(%jl_value_t addrspace(10)*, %jl_value_t addrspace(10)**, i32) #0 {
# L23:
# %3 = alloca %jl_value_t addrspace(10)**, align 8
# store volatile %jl_value_t addrspace(10)** %1, %jl_value_t addrspace(10)*** %3, align 8
# call void @julia_println_12216(i64 70)
# ret %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 4423548936 to %jl_value_t*) to %jl_value_t addrspace(10)*)
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment