gallivm: use llvm.nearbyint instead of llvm.round.
authorRoland Scheidegger <sroland@vmware.com>
Wed, 13 Apr 2016 03:00:03 +0000 (05:00 +0200)
committerJose Fonseca <jfonseca@vmware.com>
Wed, 13 Apr 2016 10:13:03 +0000 (11:13 +0100)
commitcb438d8b3e1e32faf714f22b308c8f9c5506209b
tree723840d484d44b60d3e9ff9fbd04b91cdf09a2f9
parentf525db6358fbaa7b4296d2e6484e0b1ae703ac78
gallivm: use llvm.nearbyint instead of llvm.round.

We used to use sse roundps intrinsic directly, but switched to use the llvm
intrinsics for rounding with e4f01da15d8c6ce3e8c77ff3ff3d2ce2574a3f7b.
However, llvm semantics follows standard math lib round function which is
specced to do roundNearestAwayFromZero but we really want roundNearestEven
(moreoever, using round generates atrocious code since the cpu can't do it
directly and it results in scalar calls to libm __roundf).
So, use llvm.nearbyint instead, which does exactly the right thing, and even
has the advantage of being available with llvm 3.3 too. (I've verified it
actually generates a roundps instruction with llvm 3.3.)

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=94909

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c