[Mesa-dev] [PATCH 5/7] util: Use SSE intrinsics in _mesa_lroundeven{f, }.

Matt Turner mattst88 at gmail.com
Mon Aug 3 18:22:43 PDT 2015

On Mon, Aug 3, 2015 at 4:17 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> Reviewed-by: Roland Scheidegger <sroland at vmware.com>


> I'm wondering though if this is really exactly implementing lrintf why
> we're using a different name and not just something like _mesa_lrintf().
> Though arguably _mesa_roundeven is the same... A different name would be
> more justifiable if this is not quite the same as lrintf (e.g. returning
> int instead of long).

Right, I can explain. In commit dd0d3a2c0f I replaced the
_mesa_round_to_even() function with _mesa_roundevenf(), which was just
a wrapper around rintf() and a convenient place to put intrinsics.

The idea was that by naming it roundeven it communicated that we
actually wanted round-to-nearest/ties-to-even behavior which rintf()
only provides under the default rounding mode. As I mentioned in that
commit, the only standard function that provides this behavior without
being affected by the rounding mode is "roundeven" which is part of a
technical specification not implemented by glibc (or other libcs that
I know of).

I reasoned that if the application called into Mesa with a non-default
rounding mode many more things than this would be broken, so it was
fine to rely on the default rounding mode.

More information about the mesa-dev mailing list