3 ms·
You can write it like this to get the compiler to generate SIMD: https://godbolt.org/z/ohvoEb7er https://godbolt.org/z/ohvoEb7er It's certainly not perfect tho
by orlp 3y ago
You can write it like this to get the compiler to generate SIMD: https://godbolt.org/z/ohvoEb7er https://godbolt.org/z/ohvoEb7er
It's certainly not perfect though (in particular the final reduction/remainder handling).
Unfortunately Rust doesn't have a proper optimizing float type. I really wish there was a type FastF32 or something similar which may be optimized using the usual transformation rules of algebra (e.g. associative property, distributive property, x + y - y = x, etc).
There is fadd_fast and co, but those are UB on NaN/infinite input.