[Mesa-dev] Optimize logbase2() function

Roland Scheidegger sroland at vmware.com
Fri Jun 3 07:44:51 PDT 2011


Am 02.06.2011 14:43, schrieb Benjamin Bellec:
> Hello,
> 
> I performed several tests of the logbase2() function.
> This function is defined and used in these files:

btw you could probably make it faster if you'd just use the x86 BSR
instruction - at least newer intel cpus handle that with a throughput of
1 per clock... (though you'd need special case for 0 since it's
undefined otherwise).
I don't think there's any portable way to take advantage of that
instruction however.
It shouldn't be in a performance critical path however, so any decent
portable implementation should do (FWIW you could replace the the +=
with |= but for newer cpus it most likely doesn't make a difference).

Roland


More information about the mesa-dev mailing list