Commit f74bd715 by Marcus Shawcroft

linux-atomic.c (__sync_val_compare_and_swap_4): Insert __builtin_expect().

2010-09-03  Marcus Shawcroft  <marcus.shawcroft@arm.com>

	* config/arm/linux-atomic.c (__sync_val_compare_and_swap_4): Insert __builtin_expect().
	(SUBWORD_VAL_CAS): Likewise.

From-SVN: r163805
parent a482b1f5
...@@ -155,12 +155,12 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) ...@@ -155,12 +155,12 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval)
{ {
actual_oldval = *ptr; actual_oldval = *ptr;
if (oldval != actual_oldval) if (__builtin_expect (oldval != actual_oldval, 0))
return actual_oldval; return actual_oldval;
fail = __kernel_cmpxchg (actual_oldval, newval, ptr); fail = __kernel_cmpxchg (actual_oldval, newval, ptr);
if (!fail) if (__builtin_expect (!fail, 1))
return oldval; return oldval;
} }
} }
...@@ -180,7 +180,8 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) ...@@ -180,7 +180,8 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval)
{ \ { \
actual_oldval = *wordptr; \ actual_oldval = *wordptr; \
\ \
if (((actual_oldval & mask) >> shift) != (unsigned int) oldval) \ if (__builtin_expect (((actual_oldval & mask) >> shift) != \
(unsigned int) oldval, 0)) \
return (actual_oldval & mask) >> shift; \ return (actual_oldval & mask) >> shift; \
\ \
actual_newval = (actual_oldval & ~mask) \ actual_newval = (actual_oldval & ~mask) \
...@@ -189,7 +190,7 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) ...@@ -189,7 +190,7 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval)
fail = __kernel_cmpxchg (actual_oldval, actual_newval, \ fail = __kernel_cmpxchg (actual_oldval, actual_newval, \
wordptr); \ wordptr); \
\ \
if (!fail) \ if (__builtin_expect (!fail, 1)) \
return oldval; \ return oldval; \
} \ } \
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment