Created
November 9, 2015 17:19
-
-
Save jwmerrill/01b04dcbe7c20718bc22 to your computer and use it in GitHub Desktop.
Float int cast native code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> function fn(x1::Float64, x2::Float64) | |
x1_int = reinterpret(UInt64, x1) | |
x2_int = reinterpret(UInt64, x2) | |
reinterpret(Float64, (x1_int + x2_int) >> 1) | |
end | |
fn (generic function with 1 method) | |
julia> @code_native fn(3.0, 4.0) | |
.section __TEXT,__text,regular,pure_instructions | |
Filename: none | |
Source line: 2 | |
pushq %rbp | |
movq %rsp, %rbp | |
Source line: 2 | |
movd %xmm0, %rcx | |
Source line: 3 | |
movd %xmm1, %rax | |
Source line: 4 | |
addq %rcx, %rax | |
shrq %rax | |
movd %rax, %xmm0 | |
popq %rbp | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment