Wow, I would have expected LLVM to handle this kind of low-level detail.
Here is `fabs`, implemented manually:
julia> f(x::Float64) = reinterpret(Float64, reinterpret(UInt64,x) & ~reinterpret(UIn64, -0.0))
Here is the resulting code:
julia> code_native(f, (Float64,))
.section __TEXT,__text,regular,pure_instructions
Filename: none
Source line: 1
push RBP
mov RBP, RSP
Source line: 1
vmovq RAX, XMM0
movabs RCX, 9223372036854775807
and RCX, RAX
vmovq XMM0, RCX
pop RBP
ret
Why doesn't LLVM use vandpd???
This is LLVM 3.3. Did you check LLVM 3.5?
I'd rather have LLVM handle this, as it has all the information it needs. But if it doesn't, then we definitely have to do this manually in Julia. If only to improve the performance of `abs` and `copysign`!
Did you raise this on the LLVM developers' list? Maybe there is a reason for this?
-erik
--
Erik Schnetter <
schn...@gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from
https://sks-keyservers.net.