Skip to content

Commit

Permalink
likely/unlikely support
Browse files Browse the repository at this point in the history
Branch mispredicution could cost performance loss. Add vr_likely
and vr_unlikely support to assist compiler.

Change-Id: I5a0a2210ea0d1f092f2543b52d0a145f38a33335
Partial-Bug: #1769570
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
  • Loading branch information
yipeng authored and yipengwa committed May 3, 2019
1 parent 698dc5c commit aee12a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/vr_os.h
Expand Up @@ -36,6 +36,11 @@
#define vr_sync_lock_test_and_set_p(a, b) __sync_lock_test_and_set((a), (b))
#define vr_sync_synchronize __sync_synchronize
#define vr_ffs_32(a) __builtin_ffs(a)
#define vr_likely(a) __builtin_expect(!!(a), 1)
#define vr_unlikely(a) __builtin_expect(!!(a), 0)
#else
#define vr_likely(a) (a)
#define vr_unlikely(a) (a)
#endif

#if defined(__linux__)
Expand Down

0 comments on commit aee12a3

Please sign in to comment.