On Wed, Mar 11, 2015 at 5:52 PM, Matt Turner <matts...@gmail.com> wrote: > +static inline float > +roundevenf(float x) > +{ > + float ret; > +#ifdef __SSE4_1__ > + __m128 m = _mm_load_ss(&x); > + m = _mm_round_ss(m, m, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); > + _mm_store_ss(&ret, m); > +#else > + /* Assume that the floating-point rounding mode has not been changed from > + * the default (Round to nearest). > + */ > + ret = rintf(x); > +#endif > + return ret; > +} > + > +static inline double > +roundeven(double x) > +{ > + double ret; > +#ifdef __SSE4_1__ > + __m128d m = _mm_load_sd(&x); > + m = _mm_round_sd(m, m, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); > + _mm_store_sd(&ret, m); > +#else > + /* Assume that the floating-point rounding mode has not been changed from > + * the default (Round to nearest). > + */ > + ret = rint(x); > +#endif > + return ret; > +}
While I'm not opposed to this style of implementation, do note that 99.9999738% of users will end up with distro-compiled packages targeting generic x86_64 and thus won't use the SSE variant. If it's really better, might make sense to do it "for real" (i.e. runtime selection), otherwise just let it go and use rint/rintf everywhere so that developers (who build their own libraries, probably with the "right" -march) will get the same behaviour as users. -ilia _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev