JuliaLang/julia — pull request #8364 by ArchRobison (2014-09-15 16:26:07+00:00)
Title: Add LLVM intrinsics for floor/ceil/trunc.

This PR adds intrinsics for floor/ceil/trunc. For this example:
```
function f(b,a)
@simd for i=1:length(a)
@inbounds b[i]=floor(a[i])
end
end
```
with LLVM 3.5 I'm seeing an improvement of about 28x on a Haswell processor for `Float32 arrays`. For `Float64` arrays, I'm getting about 4x improvement. Even with just LLVM 3.3, which can't vectorize `floor`, I'm seeing about 2.8x improvement for both `Float32` and `Float64`.

The patch improves the "vector" `floor` from `base/math.jl` by about 1.4x (`Float32`) or 1.8x (`Float64`) using LLVM 3.3.

While writing this patch, I discovered that the tests do not test whether "vector" `floor`, `ceil`, and `trunc` work at all. I'm happy to write such tests. I'm just not sure whether they belong in `test/math.jl` or `test/numbers.jl`. Latter is where the scalar tests for `floor`, `ceil`, and `trunc` are.