Brian Paul <bri...@vmware.com> writes: > On 03/02/2015 04:03 PM, Eric Anholt wrote: >> Kenneth Graunke <kenn...@whitecape.org> writes: >> >>> Generated by the following Coccinelle semantic patch: >>> >>> @@ >>> expression E; >>> @@ >>> if ( >>> -E >>> +unlikely(E) >>> ) >>> { ... _mesa_error(...) ... } >>> >>> Improves performance in OglBatch7 (a CPU-bound microbenchmark) on >>> an i7 4750HQ (Haswell) by 1.08546% +/- 0.519734% (n=292). >>> >>> Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> >> >> Neat! >> >> I think you're supposed to be able to get the same result by marking >> _mesa_error as attribute cold. Then nobody can forget to mark their >> conditions as unlikely in the future. > > I suspect unlikely() would be supported by more compilers than 'cold'.
gcc does it since 4.3, at least, and apparently clang does too. It means that we don't have to reply to everyone's patches in the future to say "hey, you forget to put unlikely() around your conditions leading to _mesa_error()". And it automatically gets code-size optimization for things like _mesa_ColorTableParameterfv(), and should get the goto to fog.c's invalid_pname as well. If some important compiler has __builtin_expect but not cold, it might make sense to land this still, along with attribute cold. But there's just no chance we're going to remember to unlikely() every condition leading to _mesa_error(), and this coccinnelle patch isn't enough to get all the win we can. (this is all assuming that attribute cold actually works as advertised)
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev