2014年2月13日 星期四

Hint GCC on branch prediction

Declare and use the macros:
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif
if (UNLIKELY(x != OK))
{
/* ... */
}

沒有留言:

張貼留言